Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #201443

Re: An appropriate directory search tool?

From <tomas@tuxteam.de>
Newsgroups linux.debian.user
Subject Re: An appropriate directory search tool?
Date 2018-10-19 17:30 +0200
Message-ID <wKESR-4nr-1@gated-at.bofh.it> (permalink)
References <wKEzv-4gD-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Fri, Oct 19, 2018 at 10:00:25AM -0500, Richard Owlett wrote:
> The "MATE Search Tool" comes close.
> 
> It can:
>   Select a starting directory.
>   Search for a specific extension.
>   Search for a keyword in file content.
> 
> It cannot:
>    Search ONLY the specified directory.
>    Return files that DO NOT contain a keyword.
> 
> I suspect what I want would most likely be what I'm looking for.
> "ls" can search by extension and stay in specified directory.
> It cannot include/exclude keywords.
> 
> My immediate problem involves only a couple dozen files so manual
> search is feasible.
> 
> Suggestions?

This would be 'find' (ok, with some little help from 'grep'). Hands down.

The man page can be a bit... intimidating, so I'd suggest to begin with
little examples and return to the man page from time to time until you
got the knack. Then it is worth it. Every bit.

To help you get started, I cooked up something implementing your "It
cannot" above. Here's the (commented) shell session:

  # Set lab rats up:
  tomas@trotzki:~$ mkdir d1 d1/d2
  tomas@trotzki:~$ cd d1
  tomas@trotzki:~/d1$ for f in f1 f2 f4 f6 d2/f1 d2/f2 ; do echo "hello world" > $f ; done
  tomas@trotzki:~/d1$ for f in f3 f5 d2/f3 ; do echo "wello horld" > $f ; done
  # Find all files containing the string "hell", limiting search
  # to one level of subdirectories (i.e. current dir, i.e. "d1"):
  tomas@trotzki:~/d1$ find . -maxdepth 1 -type f \( -exec grep -q "hell" {} \; -o -print \)
  ./f5
  ./f3
  # Same, but dropping the limit to one level:
  tomas@trotzki:~/d1$ find . -type f \( -exec grep -q "hell" {} \; -o -print \)
  ./d2/f3
  ./f5
  ./f3

Hope that tickled your curiosity :-)

Cheers
-- t

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-19 17:10 +0200
  Re: An appropriate directory search tool? Roberto C. Sánchez <roberto@debian.org> - 2018-10-19 17:20 +0200
  Re: An appropriate directory search tool? Roberto C. Sánchez <roberto@debian.org> - 2018-10-19 17:20 +0200
  Re: An appropriate directory search tool? <tomas@tuxteam.de> - 2018-10-19 17:30 +0200
    Re: An appropriate directory search tool? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-19 17:40 +0200
      Re: An appropriate directory search tool? <tomas@tuxteam.de> - 2018-10-19 17:50 +0200
      Re: An appropriate directory search tool? rhkramer@gmail.com - 2018-10-20 15:30 +0200
  Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-19 17:50 +0200
    Re: An appropriate directory search tool? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-19 18:10 +0200
      Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-30 16:00 +0100
        Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-12-01 18:20 +0100
  Re: An appropriate directory search tool? songbird <songbird@anthive.com> - 2018-10-20 00:40 +0200
  Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-20 11:40 +0200
    Re: An appropriate directory search tool? <tomas@tuxteam.de> - 2018-10-20 11:50 +0200
      Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-20 12:30 +0200
        Re: An appropriate directory search tool? Joe <joe@jretrading.com> - 2018-10-20 13:40 +0200
          Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-20 14:30 +0200
            Re: An appropriate directory search tool? Brian <ad44@cityscape.co.uk> - 2018-10-20 21:10 +0200
              Re: An appropriate directory search tool? Håkon Alstadheim <hakon@alstadheim.priv.no> - 2018-10-21 00:00 +0200
                Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-21 12:10 +0200
              Re: An appropriate directory search tool? Andrew McGlashan <andrew.mcglashan@affinityvision.com.au> - 2018-10-21 11:00 +0200
                Re: An appropriate directory search tool? <tomas@tuxteam.de> - 2018-10-21 11:20 +0200
        Re: An appropriate directory search tool? Roberto C. Sánchez <roberto@debian.org> - 2018-10-20 14:10 +0200
        Re: An appropriate directory search tool? John Crawley <john@bunsenlabs.org> - 2018-10-21 03:20 +0200
          Re: An appropriate directory search tool? mick crane <mick.crane@gmail.com> - 2018-10-21 07:30 +0200
          Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-21 12:30 +0200
            Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-21 15:50 +0200
              Re: An appropriate directory search tool? rhkramer@gmail.com - 2018-10-21 16:40 +0200
                Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-21 17:30 +0200
                Re: An appropriate directory search tool? rhkramer@gmail.com - 2018-10-21 17:50 +0200
                Re: An appropriate directory search tool? Curt <curty@free.fr> - 2018-10-21 18:40 +0200
                Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-21 18:40 +0200
                Re: An appropriate directory search tool? rhkramer@gmail.com - 2018-10-21 19:20 +0200
                Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-21 21:00 +0200
                Re: An appropriate directory search tool? rhkramer@gmail.com - 2018-10-21 23:50 +0200
              Re: An appropriate directory search tool? John Crawley <john@bunsenlabs.org> - 2018-10-22 03:20 +0200
                Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-22 17:30 +0200
              Re: An appropriate directory search tool? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-22 15:20 +0200
                Re: An appropriate directory search tool? David Wright <deblis@lionunicorn.co.uk> - 2018-10-22 17:30 +0200
                Re: An appropriate directory search tool? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-22 17:50 +0200
        Re: An appropriate directory search tool? Curt <curty@free.fr> - 2018-10-21 12:00 +0200
      Re: An appropriate directory search tool? Joe <joe@jretrading.com> - 2018-10-20 13:30 +0200
        Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-20 14:30 +0200
    Re: An appropriate directory search tool? Étienne Mollier <etienne.mollier@mailoo.org> - 2018-10-20 12:30 +0200
      Re: An appropriate directory search tool? Richard Owlett <rowlett@cloud85.net> - 2018-10-20 14:40 +0200
        Re: An appropriate directory search tool? Dan Purgert <dan@djph.net> - 2018-10-20 15:20 +0200
        Re: An appropriate directory search tool? rhkramer@gmail.com - 2018-10-20 15:30 +0200

csiph-web