linux命令---查找文件中的內容


linux命令---查找文件中的內容  

 

[yang@localhost ~]$ cat 1.txt |egrep '123456789|second'-------匹配123456789或者second的行

first line:123456789012345678901234567890123456789012345678901234567890

second line:one two three four five six seven eight nine ten

 

[yang@localhost ~]$ cat 1.txt |egrep 'two' |egrep 'one'----匹配two 且匹配one的行

second line:one two three four five six seven eight nine ten

 

[yang@localhost ~]$ cat 1.txt |grep 'two' |grep 'one'----匹配two 且匹配one的行

second line:one two three four five six seven eight nine ten

 

 

[yang@localhost ~]$ grep -o 123456789 1.txt |wc -l  -----123456789出現的次數

6

[yang@localhost ~]$ cat 1.txt |grep -o 123456789 |wc -l    -----123456789出現的次數

6

[yang@localhost ~]$ more 1.txt |grep -o 123456789 |wc -l  -----123456789出現的次數

6

[yang@localhost ~]$

 

 

 

[yang@localhost ~]$ more 1.txt |grep -o 'one..........two' |wc -l   -----------'one..........two'出現的次數,中間10個點表示隔了10個字

1

[yang@localhost ~]$ cat -n 1.txt |grep 'one..........two'      ----------匹配'one..........two'的行,中間10個點表示隔了10個字

    53     one1234567890two

[yang@localhost ~]$


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM