Linux command: grep 用grep命令匹配一行多个字符串

 

How to use grep to match multiple strings in the same line?

grep 'string1\|string2' filename
grep -E "string1|string2" filename


How can I grep for a string that begins with a dash/hyphen?


1. Quote AND/OR escape
Code:
 ls | grep "\-a"
(that \ is the escape character)
or
2. Use flag "--" to stop switch parsing
Code:
ls | grep -- -a
posted @ 2017-12-02 07:18  emanlee  阅读(944)  评论(0)    收藏  举报