Author Topic: Need to find a key word  (Read 1259 times)

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Need to find a key word
« on: 21 October 2002, 06:45 »
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

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Need to find a key word
« Reply #1 on: 21 October 2002, 06:52 »
never mind, got it.

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Need to find a key word
« Reply #2 on: 21 October 2002, 07:54 »
if anyone's intrested:

# grep keyword -r /path/to/directory

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Need to find a key word
« Reply #3 on: 21 October 2002, 08:00 »
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: [Select]

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 ]

Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Need to find a key word
« Reply #4 on: 21 October 2002, 08:15 »
No problem! In the FAQ it goes.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Need to find a key word
« Reply #5 on: 21 October 2002, 08:49 »
Just realized there is a graphical tool called "kfind" that works much like the graphical find in M$ and possible MacOS. I like my command line though..
Someone please remove this account. Thanks...