Operating Systems > Linux and UNIX

Need to find a key word

(1/2) > >>

TheQuirk:
I need to find the word "home" and what file it's in, from a directory and it's sub directories. I don't remember how to do this, though. The last time I did it was when I grepped the Kernel source code for the word "fuck..."

TheQuirk:
never mind, got it.

TheQuirk:
if anyone's intrested:

# grep keyword -r /path/to/directory

voidmain:
WOW! When was the "-r" parameter added to grep?  See, this is why I like UNIX. No matter how long you've been using it, someone comes up with something stupid simple that you've been missing out on to make your life even more efficient than it was before. I wrote a friggin command long ago that uses the "find" and "grep" commands together to do this and always stuck it in my /usr/bin directory. Duh! Guess I should browse the man pages every couple of releases to see what other goodies have been added.    

Thanks for posting that Quirk!

[edit]

I just made a little script called "findtext" with the options I use most:


--- Code: ---
--- End code ---

which will search non binary files and return only the file names that match (does not show matching text). Also suppresses error message (permission denied etc). To use it:

$ findtext keyword directory

[/edit]

[ October 20, 2002: Message edited by: void main ]

TheQuirk:
No problem! In the FAQ it goes.

Navigation

[0] Message Index

[#] Next page

Go to full version