Having trouble finding a word in multiple files

Chris Green cl at isbd.net
Sun Jun 14 08:23:21 UTC 2020


On Sun, Jun 14, 2020 at 09:19:04AM +0100, Peter Flynn wrote:
> On 14/06/2020 08:53, Pat Brown wrote:
> > I've tried a variety of grep commands but I can't find the specific word
> > I'm searching for that is in a file or files somewhere in my Dropbox
> > folder. The word I'm trying to find is Blowback. Can someone please help
> > me with the correct command?
> 
> I don't use Dropbox, so I'm not familiar with what "a Dropbox folder" is. Is
> it a real directory on your disk containing actual files, or is it some kind
> of soft link to a network location at dropbox.com, and the files are
> actually stored out there on their machine, not yours?
> 
> If they are files and directories physically stored on your disk, then the
> find and grep utilities will work like this:
> 
> $ find ~/Dropbox -type f -name '*' -exec grep -il blowback {} \;
> 
There's no need for the find, a recursive grep will do the same:-

    grep -ir blowback ~/Dropboc

> Replace ~/Dropbox with whatever your Dropbox directory is called.
> This finds all normal files (type f) with any name (name '*') and then runs
> grep on each one in turn and looks for caseless 'blowback' and just gives
> the filename of successful searches, not the entire line of text.
> 
> grep can read some non-text file formats but I don't know what it does with
> binaries like .docx
> 
> If the Dropbox folder is a link to files elsewhere, I don't know what will
> happen — I'd be very interested to learn :-)
> 
Quite, there might be a specific tool for the job, there are lots of
grep lookalikes for things like this.

-- 
Chris Green




More information about the ubuntu-users mailing list