Need help writing compound linux query

GPGVM

Trying to write my first compund linux query and running into some gaps in knowledge.

The idea is to find all the file that may be either .doc or .txt as well as search the contents for the text clown.

So I started off with searching from the root as such.

$find /

Then I added the wildcard for filename.'

$find / -name '*.doc'...uhh oh

First question. How do I specify or? Is it with pipe | or double pipe || or...? and do I need to repeat the -name parameter like this?

$find / -name '*.doc' || -name '*.txt'

Second ? do I add the grep for the string after / before...?

$find / -name '*.doc' || -name '*.txt' grep -H 'cat' {} \

Finally is there a place where I can validate syntax / run like SQLFiddle?

TIA

jam

'Or' in find is -o

You have to specify the find type again though. So something like:

find / -name *.doc -o -name *.txt

You can simply put your grep command in front, so long as you encase your find command in backticks:

grep 'whatever' `find / -name *.doc -o -name *.txt`

There's a reasonably nice guide to find here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related