[KLUG Members] grep, egrep, fgrep

John Pesce members@kalamazoolinux.org
06 May 2004 10:04:13 -0400


Hi,

Can anyone explain why there are still three different greps?
One of my associates says that they each were written for a purpose but
supposedly their functionality should all be combined into just plain
grep now.

The reason I ask is I often need to search for filenames with a period
in my pattern, like '.s' , for filenames like file.sam using a comand
like (ls -1 | fgrep -e '.s') . The man pages say I should use -e '.s' to
tell grep not to interpret the period. However only fgrep -e '.s' works
as grep and egrep return anything with an s in it. Should I still be
escaping the period somehow anyway?

I also can't seem to figure out how to search a file for lines
containing either one thing or another in file order. Something like
grep 'A or B' file.txt

Thanks
John