linux grep多条件匹配数据


1、创建测试数据

[root@linuxprobe test3]# cat a.txt w r t f s 4 6 6 a g g s d g r 4 d e w h s f g h

 

2、

[root@linuxprobe test3]# grep -E '^w|^a|h$' a.txt ## 提取以w开头或者以a开头或者以h结尾的行 w r t f a g g s d e w h s f g h

 

 

3、

[root@linuxprobe test3]# grep -E 'f|^a|h$' a.txt ## 提取包含f的行或者以a开头的行或者以h结尾的行 w r t f a g g s d e w h s f g h

 

 

4、

[root@linuxprobe test3]# grep '^d' a.txt | grep 'h$' ##提取同时满足以d开头,同时以h结尾的行 d e w h

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM