欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

请教sed 多条件的与或处理 并且 或者

同时匹配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'


来自 https://zhidao.baidu.com/question/430076056664891372.html


用sed、awk、grep同时匹配多个条件(与模式、或模式)

同时匹配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'


来自 https://www.cnblogs.com/fjping0606/p/4997643.html

普通分类: