//View Tip #743
Similar Tips
» Grepping for processes
» List non-system users
» Moved Trac and Subversion repositories to another machine/direct
» BBC Weather
» Print a random shell-fu tip

 

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.

Options:

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


View Comments »




Comments 

Add your comment

Comments are currently disabled
name
grep word /dir/*
Posted 2009-05-01 09:00:05
SteveG
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