Note that you use quotation marks around your phrase because you are searching for a phrase. If you're searching for a word, you don't need quotation marks.
To search in a directory of text files for the phrase "Libby the dog", try this:
grep "Libby the dog" *.txt
By default, grep searches are case-sensitive. If you grep for "dog", you will NOT see results for "Dog". To search in a directory of text files for the word "dog" or "Dog", try this:
grep -i dog *.txt
To search in a directory of text files for word "dog" or "Dog" and thenautomatically have the results of that search entered into a text file called"dogsearch.txt", try this:
grep -i dog *.txt > dogsearch.txt
To find out how many times the word "dog" is used in a text file, try this:
grep -c dog file.txt
Contact
WorkFor work info, see WebSanity. |
All content, unless under a Creative Commons license, is © 1997-2011 Scott Granneman. (Take a look around—a lot of content is licensed under a Creative Commons license, which gives YOU a lot of freedom to reuse my work.) |
|