On Wed, 2006-01-18 at 13:44 -0500, Randy Grimshaw wrote: > > > <><Randall Grimshaw > Room 203 Machinery Hall > Syracuse University > Syracuse, NY 13244 > 315-443-5779 > rgrimsha@xxxxxxx > > >>> rengland@xxxxxxxxxx 1/18/2006 1:31:50 PM >>> > > chalonec wrote: > >> I have installed FC4 and am looking for a command line way to search all > >> files in all directories and sub-directories on a disk for files that > >> contain a certain text string such as the word gateway or mode or any > >> word. > > here is my trick: > du -a {path} | grep {word} > This finds a all directories and files which name contains {word} that are located in and below {path}. It doesn't find files that contain {word}. > I generally store the results so that future searches are very fast - like this: > mkdir /usr/local/where > du -a / > /usr/local/where/was.txt > This stores all file and directory names that are in / and below in /usr/local/where/was.txt > and create a shell script that does the grep > > echo "grep $1 /usr/local/where/was.txt" > /usr/local/bin/ww This takes the list of files and directories from above and searches for the first command line argument ($1) in that list and stores what it finds in /usr/local/bin/ww > chmod +x /usr/local/bin/ww > This makes /usr/local/bin/ww executable to everyone. It's unlikely at this point that /usr/local/bin/ww is a correct shell script. > so now I just have to do > ww {word} > This tries to execute the file that was just created with {word} as it's first command line argument. > such as > ww tgz$ > This tries to execute the file that was just created with tgz$ as it's first command line argument. > it is also handy after a package install by storing the results to a different name, diff the old and new files, grep -v proc to remove the noise. In this way you can get a rough sense of changes made to your system. > The -v option to grep inverts the match, so grep -v proc would search for lines not containing proc. If I read chalonec's question correctly, he wanted to "search all files in all directories and sub-directories on a disk for files that contain a certain text string such as the word gateway or mode or any word." Paul Howarth answered that question very well, so I won't answer it again. I was just trying to understand how your solution solves the problem? -- Tony Heaton - "If you do nothing, they'll win"
Attachment:
signature.asc
Description: This is a digitally signed message part