How to do grep without regex (fixed string)

Linux (or Unix) grep without any options does a regex grep on input stream. To disable regex either one can use grep -F or fgrep. Here are some examples.

Default grep example

printf "foophp\nfoo.php\n" | grep ".php"
foophp
foo.php
Env: GNU bash, version 4.3.11

grep without regex example

printf "foophp\nfoo.php\n" | grep -F ".php"
foo.php
Env: GNU bash, version 4.3.11

fgrep example

printf "foophp\nfoo.php\n" | fgrep ".php"
foo.php
Env: GNU bash, version 4.3.11
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments