1. Home
  2. Computing & Technology
  3. Linux
grep Command
<Linux Glossary>

 Related Terms
• User Commands
 
 
Definition: Unix command "grep" allows you to search for a pattern in a list of files. Such patterns are specified as "regular expressions", which in their simplest form are "strings", such as words or sentence fragments.

The way we search for a string with grep is to put the words we are searching for together in single quotes.

  • The syntax: % grep pattern file-name-1 file-name-2 …file-name-n
  • An example: % grep 'mountain bike' sports hobbies

As a result of entering this command the operating system will print all the lines in the file "sports" and the file "hobbies" that contain the string "mountain bike". By default the line will be printed on the computer screen (in the shell window, where the command was issued).

Related Resources:

Command Library
Unix commands are introducted one by one, with examples.

<Linux Glossary>

 

Explore Linux
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.