Linux egrep命令詳解 Linux egrep命令怎麼用

來源:互聯網
上載者:User

egrep執行效果與"grep-E"相似,使用的文法及參數可參照grep指令,與grep的不同點在於解讀字串的方法。

egrep是用extended regular expression文法來解讀的,而grep則用basic regular expression 文法解讀,extended regular expression比basic regular expression的表達更規範。

文法

egrep [範本模式] [檔案或目錄]

參數說明:

  • [範本模式] :尋找的字串規則。
  • [檔案或目錄] :尋找的目標檔案或目錄。

執行個體

顯示檔案中合格字元。例如,尋找目前的目錄下所有檔案中包含字串"Linux"的檔案,可以使用如下命令:

egrep Linux *

結果如下所示:

$ egrep Linux * #尋找目前的目錄下包含字串“Linux”的檔案

testfile:hello Linux! #以下五行為testfile 中包含Linux字元的行

testfile:Linux is a free Unix-type operating system.

testfile:This is a Linux testfile!

testfile:Linux

testfile:Linux

testfile1:helLinux! #以下兩行為testfile1中含Linux字元的行

testfile1:This a Linux testfile!

#以下兩行為testfile_2 中包含Linux字元的行

testfile_2:Linux is a free unix-type opterating system.

testfile_2:Linux test

xx00:hello Linux! #xx00包含Linux字元的行

xx01:Linux is a free Unix-type operating system. #以下三行為xx01包含Linux字元的行

xx01:This is a Linux testfile!

xx01:Linux

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.