search | site map

Scott Granneman

panorama-025.jpg
  • Writing
    • Books
    • SecurityFocus
    • Linux Magazine
    • Others
    • Swings & Misses
  • Presentations
    • Interviews
    • Ladue Chapel
  • Teaching
    • Current Courses
    • Student Evaluations
    • Washington University
    • Webster University
    • St. Louis Community College
    • Archives
  • Web Development
    • Becoming a Web Developer
    • Coding
    • Programming
    • Editors
    • Web Browsers
    • Domains
    • Hosting
    • Graphics & Multimedia
    • Content
  • Tech Info
    • Background
    • Tools
    • Intellectual Property
    • Security
    • Email
    • Networking
    • Blogs, Podcasts, RSS
    • Search
    • Linux
    • Windows
    • Education
  • Personal
    • Work
    • Movies
    • Music
    • Reading
    • Poetry
    • Prose
    • Photos
    • Journals
    • Commonplace Book
    • Our Home
    • Opinions & Editorials
Home > Tech Info > Linux > Command Line > Find Stuff > grep

Search Text Files for a Particular Word or Phrase

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

Email scott@granneman.com
Voice 314-780-0489
Address
39 Summit Place
St. Louis, MO 63119
United States

Work

For 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.)

facebook_32.png Facebook   twitter_32.png Twitter
linkedin_32.png LinkedIn   friendfeed_32.png FriendFeed
flickr_32.png Flickr   lastfm_32.png Last.fm
youtube_32.png YouTube   rss_32.png RSS