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