linux系統中grep的使用講解,linux系統grep講解

來源:互聯網
上載者:User

linux系統中grep的使用講解,linux系統grep講解

1.grep -E "addFavStation

查詢包含“addFavStation”或者包含“收藏送券參數:” 的資料

2.grep "SinochemController" web-info.log.2018-03-18| grep "收藏成功,派券失敗" | grep "addFavStation"

查詢即包含“SinochemController” 又包含“addFavStation”,“收藏成功,派券失敗”

注意:web-info.log.2018-03-18 必須放在第1個grep後面,

3.grep "addFavStation"| grep "收藏成功,派券失敗" web-info.log.2018-03-18| grep "SinochemController"

這個不全是邏輯與 查詢結果並不是3個條件的

4.grep "SinochemController"|grep "addFavStation" |grep "收藏送券參數:" web-info.log.2018-03-18

這樣的不是“與” 查詢

5.grep "SinochemController" web-info.log.2018-03-18|grep "addFavStation"|grep "收藏油站通知卡系統==================結束"

解釋:

grep命令是一種強大的文本搜尋工具,它能使用Regex搜尋文本,並把匹 配的行列印出來。

grep全稱是Global Regular Expression Print,表示全域Regex版本,它的使用許可權是所有使用者

grep -i pattern files :不區分大小寫地搜尋。預設情況區分大小寫,

grep -l pattern files :只列出匹配的檔案名稱,

grep -L pattern files :列出不匹配的檔案名稱,

grep -w pattern files :只匹配整個單詞,而不是字串的一部分(如匹配‘magic’,而不是‘magical’),

grep -C number pattern files :匹配的上下文分別顯示[number]行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.