Friday, August 12, 2011

egrep–useful linux command

 

suppose we want to search for a string “abc” in a file then we use

grep “abc” /path/to/file/file.txt

but what if u want to search for either “abc” or “xyz”? u need to grep twice. instead use egrep

egrep “abc|xyz” /path/to/file/file.txt

the best use of egrep comes in when we tail a file and want to search for a set of strings in the tail eg:

tail –f /path/to/file/file.txt | egrep “abc|xyz”

No comments:

Post a Comment