Search for text in desired files

All about shell scripts.
Post Reply
thomas

Search for text in desired files

Post by thomas » Fri Jan 23, 2009 9:45 am

To find the string "author" in all files with the suffix ".c" in and below the directory "~/src".

Code: Select all

find ~/src -iname '*.c' -print0 | xargs -0 grep -i author
The match for the files and text is case insensitive (-iname, grep -i).
It's generally a good idea to use the "-print0" and "xargs -0" command if any filenames containing single or double quotes, spaces or newlines. :!:

Post Reply