# To list files that contain "the phrase" grep 'the phrase' -li -r /etc
# To search for "the phrase" within a specific file grep 'the phrase' /etc/httpd/conf/httpd.confThis command is particularily useful if you're searching a folder full of MS Word docs. Word docs aren't plain text files (duh) and therefore don't get matched properly by most application level search features (e.g. TextWrangler).
The 'l' option is shorthand for '--files-with-matches'. Only the names of files containing selected lines are written to standard output.
The 'i' option is shorthand for '--ignore-case'. Omit this option if you do want your search to be case sensitive.
Lastly, the 'r' option is shorthand for '--recursive'. This tells grep to recursively search the subdirectories listed. This is key when you're interested in searching a folder full of docs (as opposed to an individual file).
No comments:
Post a Comment