linux grep命令操作指南

來源:互聯網
上載者:User

          ① 定義
         
             grep是行級裝置,它分析一行資訊,若當中有我們所需要的資訊,就將整行返回
            
          ② 作用
         
             進行字串資料的對比,將符合使用者需求的字串列印出來
            
          ③ 格式
         
             grep [-acinv] [--color=auto] '尋找字串' filename
            
             參數:
             -a:將二進位檔案一text檔案的方式尋找資料
             -c:計算找到‘尋找字串’的次數
             -i:對大小寫透明
             -n:輸出行號
             -v:顯示沒有‘尋找字串’內容的那一行
             -A:後面可加數字,為after的意思,除了列出該行外,後續的n行也列出來
             -B:後面可加數字,為before的意思,除了列出該行外,前面的n行也列出來
             --color=auto:關鍵字上色

          ④ 例子
             eg01:找出有檢查點事件發生的標誌

[oracle@localhost bdump]$ grep -in --color=auto 'checkpoint' alert_orcl.log64:  checkpoint is 44607466:  checkpoint is 44607469:  checkpoint is 44607472:  checkpoint is 446074383:  checkpoint is 4602001845:Checkpoint not complete2112:  checkpoint is 6062172114:  checkpoint is 6062172116:  checkpoint is 6062172118:  checkpoint is 6062172120:  checkpoint is 606217

            eg02:從核心中找出網卡相關資訊

[oracle@localhost bdump]$ dmesg | grep -n -A3 -B2 --color=auto 'eth'599-iscsi: registered transport (iser)600-iscsi: registered transport (be2iscsi)601:eth0: no IPv6 routers present602-Bluetooth: Core ver 2.10603-NET: Registered protocol family 31604-Bluetooth: HCI device and connection manager initialized--615-ip_conntrack version 2.4 (8192 buckets, 65536 max) - 228 bytes per conntrack616-ip6_tables: (C) 2000-2006 Netfilter Core Team617:peth0: Promiscuous mode enabled.618:device peth0 entered promiscuous mode619:xenbr0: port 1(peth0) entering forwarding state620-device vif0.0 entered promiscuous mode621-New device vif0.0 does not support netpoll622-Disabling netpoll for xenbr0--625-hdc: drive_cmd: error=0x04 { AbortedCommand }626-ide: failed opcode was: 0xec627:eth0: no IPv6 routers present628:xenbr0: port 1(peth0) entering disabled state629:xenbr0: port 1(peth0) entering forwarding state

 

相關文章

聯繫我們

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