gasilpublishing.blogg.se

Egrep vs grep
Egrep vs grep









to return lines that start with either "nofork" or "nogroup". You could run this search using -E: grep -E '^no(fork|group)' /etc/group For example parenthesis () can be used to indicate groups with | used as an OR operator. You want to search using a fancy expression. Dots for example would be interpreted as dots rather than wild-cards. The reason the -F switch helps here is that the usernames in your pattern file are interpreted as plain text strings. You want to search the group file on your machine to see if any of the ten users listed are in any special groups: grep -F -f user_list.txt /etc/group You have a file with a list of say ten Unix usernames in plain text. Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. The -F switch switches grep into a different mode where it accepts a pattern to match, but then splits that pattern up into one search string per line and does an OR search on any of the strings without doing any special pattern matching.

egrep vs grep

This version of grep is efficient and fast when it comes to searching for a regular expression pattern as it treats meta-characters as is and doesn’t substitute them as strings like in grep, and hence you are freed from the burden of escaping them as in grep. Interpret PATTERN as an extended regular expression Egrep or grep -E is another version of grep or the Extended grep. Details of this syntax are on the man page. The man page for grep has details about this.Īs for what they do, -E switches grep into a special mode so that the expression is evaluated as an ERE (Extended Regular Expression) as opposed to its normal pattern matching. On some really old Unix systems you will find that you need to call the separate binaries, but on all modern systems the switches are preferred.

egrep vs grep

Historically these switches were provided in separate binaries.











Egrep vs grep