$ grep -E ‘string-1|string-2|regexp-1|regexp-n’

In the sample output:

The first 4 lines of the grep output are the result of the first matchstring/regexp (pts),

next 4 lines are the result of the second matchstring/regexp (tty).. so on.

*Note:

The demo text-file has been hand-crafted to demonstrate the use of grep.

Do not try to find (mis)logic in the output of ps ! ;)

View this command to comment, vote or add to favourites
View all commands by b_t

commandlinefu.com

by David Winterbottom (codeinthehole.com)


Tags: