User Tools

Site Tools


grep:basic_usage

This is an old revision of the document!


Grep - Basic usage

Assuming a file exists with the following contents:

boot
book
booze
machine
boots
bungie
bark
aardvark
broken$tuff
robots

grep "boo" filename

returns:

boot
book
booze
boots

NOTE: grep prints out every line that contains the word boo.


Simple Search with Line Numbers

grep -n "boo" filename

returns:

1:boot
2:book
3:booze
5:boots

NOTE: Using the -n option prints includes line numbers.


Simple Inverse Search with Line Numbers

grep -vn "boo" filename

returns:

4:machine
6:bungie
7:bark
8:aaradvark
9:robots

NOTE: Using the -v option prints the inverse of the search string.

This is the items not found.

grep/basic_usage.1598093433.txt.gz · Last modified: 2020/08/22 10:50 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki