Hi Wonder if someone could give me the way to grep for an word within all files on my system like the filename would be XXXX.XX seems no matter what i been trying i am just not doing it right thanks in advance Bob
N1UAN Bob wrote:
Wonder if someone could give me the way to grep for an word within all files on my system like the filename would be XXXX.XX
find / -type f -iname '????\.??' | xargs grep -i 'word' will do a case insensitive file match for all files with 4 chars followed by a literal '.' followed by 2 chars then do a case insensitive search for 'word' on those files. HTH, BR
Adding /dev/null below so that grep outputs the filename(s) it found the pattern match in. Without it, grep will only print out the line containing the match. Sorry about the original mail :-) BR Brett Russ wrote:
N1UAN Bob wrote:
Wonder if someone could give me the way to grep for an word within all files on my system like the filename would be XXXX.XX
find / -type f -iname '????\.??' | xargs grep -i 'word' /dev/null
will do a case insensitive file match for all files with 4 chars followed by a literal '.' followed by 2 chars then do a case insensitive search for 'word' on those files.
HTH, BR
N1UAN Bob wrote:
Hi Wonder if someone could give me the way to grep for an word within all files on my system like the filename would be XXXX.XX seems no matter what i been trying i am just not doing it right thanks in advance Bob
You might try the following, from O'Reilly's "Unix Power Tools" find . -type f -print | xargs fgrep 'text' /dev/null Replace "text" with the word you're looking for. You might also want to replace the "." after find, with "/", to start from /, instead of the current directory.
Using bash:
grep "MyWordOfInterest" $(find / -type f -iname '????\.??')
The command1 $(command2) expression executes command2 and replace $(command2) with its own output. It's not really fast but is really easy to concatenate it to make complex searchs. With other shells use the `command2` instead of $(command2) where ` is the "inverted tilde". Maybe you need this if working as root with a simpler shell. --- N1UAN Bob <bobbru@chartertn.net> escribió: > Hi
Wonder if someone could give me the way to grep for an word within all files on my system like the filename would be XXXX.XX seems no matter what i been trying i am just not doing it right thanks in advance Bob
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
participants (4)
-
Brett Russ
-
Enrique Arizón
-
James Knott
-
N1UAN Bob