I'm console newbie. As I know, matching multiple patterns like this:
aaa|bbb
But, | character is pipe on console, so how can I specify those multiple patterns for grep?
|
I'm console newbie. As I know, matching multiple patterns like this:
But, | character is pipe on console, so how can I specify those multiple patterns for grep?
| |||
|
feedback
|
|
You can escape the pipe and put the pattern in quotes:
or use
or
| |||||||||
feedback
|
|
Or you go
to grep for aaa or bbb in filename, case insensitively. | |||
|
feedback
|
|
Lastly, you can put your patterns into a file, and use the -f flag. So aaa bbbMake sure there are no empty lines, though. --Christopher Karel | |||
|
feedback
|
|
Enclose your pattern in single quotes:
Should your pattern include an apostrophe, enclose it in double quotes:
If it contains both single and double quotes, enclose it in double quotes and prefix with a backslash the characters ", $, ` and \:
The final example of PS: The bash quoting page is a must-read. | |||
|
feedback
|
|
i wonder why this won't work grep -v 'DST=255.255.255.255\|DST=192.168.1.255' | |||
|
feedback
|
|
will find all rows with either aaa OR bbb OR ccc in the file
will find | |||
|
feedback
|