Search This Blog

Showing posts with label grep regular expression. Show all posts
Showing posts with label grep regular expression. Show all posts

Sunday, July 31, 2011

Use grep and regular expressions to analyze text

1) grep 'word' filename

2)cat filename | grep 'something'

Regular expressions

1)The following example displays lines starting with the vivek only
grep ^vivek /etc/passwd

2)Find lines ending with word foo:
grep 'foo$' filename

3)Match line only containing foo:
grep '^foo$' filename

4)You can match two numeric digits (i.e. match foo11, foo12 etc):
grep 'foo[0-9][0-9]' filename