Click to See Complete Forum and Search --> : searching directories for files with grep?


scoobydope
01-19-2001, 12:26 AM
must be possible. is there a flag that i can use in combination.... suppose i want to find a file with the string 'swat' in the name of the file....?

or do you just use a find...or a locate?

jemfinch
01-19-2001, 01:01 AM
"find -regex" if you want to find files whose names match a regexp.

Jeremy

klamath
01-19-2001, 01:03 AM
Just do a 'ls|grep foo'.

------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the Better Bulletin Board (http://bbb.sourceforge.net)

scoobydope
01-19-2001, 01:07 PM
ok, what about finding a string in a file... out of a list of files....

say i have the line 'rmdir -f /etc'
in some script somewhere in one of 30 scripts in the directory /dumbscript..

is there a way to locate that line by somehow scanning all the files from a single grep?

I think that is more what i am trying to ask.

klamath
01-19-2001, 02:31 PM
grep -d skip 'hello world' /etc/*

If you need to recurse directories under /etc, something like:

find /etc -type f -exec 'grep "hello world" {}' ';'

or just

grep -r 'hello world' /etc/*

------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the Better Bulletin Board (http://bbb.sourceforge.net)