Linux Shell Scripting Tutorial (LSST) v1.05r3
Prev
Chapter 5: Essential Utilities for Power User
Next

Finding matching pattern using grep utility

Create text file as follows:

demo-file

hello world!
cartoons are good
especially toon like tom (cat)
what
the number one song
12221
they love us
I too

After saving file, issue following command,
$ grep "too" demofile
cartoons are good
especially toon like tom (cat)
I too

grep will locate all lines for the "too" pattern and print all (matched) such line on-screen. grep prints too, as well as cartoons and toon; because grep treat "too" as expression. Expression by grep is read as the letter t followed by o and so on. So if this expression is found any where on line its printed. grep don't understand words.

Syntax:
grep "word-to-find" {file-name}


Prev
Home
Next
Removing duplicate lines from text database file using uniq utility
Up
Learning expressions with ex