//View Tip #743
Similar Tips
» Moved Trac and Subversion repositories to another machine/direct
» Find words in garbled text
» Get real names of current users
» Check memory and swap from command line
» Get latest stable version of the Linux kernel


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
I've often seen people using the find command on a directory to get all the files, then using these with grep to find files containing a particular word. This can however, be done better just using grep:

grep --color=auto -inHR "search_for" /in/dir

greps for occurances of 'search_for' in the specified directory and below, or the current directory if none specified.


-i case insensitive
-n shows line number
-H shows file name
-R recursive

View Comments »


Add your comment

Comments are currently disabled
grep word /dir/*
Posted 2009-05-01 09:00:05
grep word /dir/*

Doesn't do remotely the same thing as the command in this tip. The command in the tip looks for files in a directory which contain a word, whereas "grep word /dir/*" searches for files where the FILENAME contains the word.
Posted 2009-05-06 10:14:52

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit