grep 使用

2019/05/24 Linux 共 305 字,约 1 分钟

基本的

grep -rin --color=auto 查找关键字 查找的文件

可设置百度输入法的个性短语来控制台查 bug,也可以 bash_profile 设置好alias grep = grep --color=auto

多文件查找

同时匹配ABC 和 123:
sed -n '/ABC/{/123/p}'        

awk '/ABC/&&/123/{ print $0 }'  


grep -E '(ABC.*123|123.*ABC)'    


匹配ABC 或 123:
sed -n '/\(ABC\|123\)/p'

awk '/ABC/||/123/{ print $0 }'

grep -E '(ABC|123)' 或 egrep 'ABC|123'

或者

grep a a.txt | grep b

Search

    Table of Contents