Google News
logo
Unix - Interview Questions
In Shell scripting, how do you separate the grep and egrep?
egrep is an extended version of grep, in addition to searching using regular expressions, egrep can use extended regular expressions for searching.
$ ls | grep '.env|.json'?

This will check whether any file has extension ‘.env|.json’ literally
$ ls | egrep '.env|.json'?

But in this case, it checks whether any file has extension ‘.env’ or ‘.json’ since ‘|’ this will be considered as a metacharacter.
Advertisement