0
点赞
收藏
分享

微信扫一扫

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

后来的六六 2023-11-06 阅读 29

 

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



举报

相关推荐

0 条评论