linux grep命令操作指南
grep是行級設備,它分析一行信息,若當中有我們所需要的信息,就將整行返回,那么你知道linux grep命令操作指南么?接下來是小編為大家收集的linux grep命令操作指南,歡迎大家閱讀:
linux grep命令操作指南
?、?定義 www.2cto.com
grep是行級設備,它分析一行信息,若當中有我們所需要的信息,就將整行返回
?、?作用
進行字符串數(shù)據(jù)的對比,將符合用戶需求的字符串打印出來
?、?格式
grep [-acinv] [--color=auto] '查找字符串' filename
參數(shù):
-a:將二進制文件一text文件的方式查找數(shù)據(jù)
-c:計算找到‘查找字符串’的次數(shù)
-i:對大小寫透明
-n:輸出行號
-v:顯示沒有‘查找字符串’內(nèi)容的那一行
-A:后面可加數(shù)字,為after的意思,除了列出該行外,后續(xù)的n行也列出來
-B:后面可加數(shù)字,為before的意思,除了列出該行外,前面的n行也列出來
--color=auto:關(guān)鍵字上色
④ 例子 www.2cto.com
eg01:找出有檢查點事件發(fā)生的標志
[sql]
[oracle@localhost bdump]$ grep -in --color=auto 'checkpoint' alert_orcl.log
64: checkpoint is 446074
66: checkpoint is 446074
69: checkpoint is 446074
72: checkpoint is 446074
383: checkpoint is 460200
1845:Checkpoint not complete
2112: checkpoint is 606217
2114: checkpoint is 606217
2116: checkpoint is 606217
2118: checkpoint is 606217
2120: checkpoint is 606217
eg02:從內(nèi)核中找出網(wǎng)卡相關(guān)信息
[sql]
[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 present
602-Bluetooth: Core ver 2.10
603-NET: Registered protocol family 31
604-Bluetooth: HCI device and connection manager initialized
--
615-ip_conntrack version 2.4 (8192 buckets, 65536 max) - 228 bytes per conntrack
616-ip6_tables: (C) 2000-2006 Netfilter Core Team
617:peth0: Promiscuous mode enabled.
618:device peth0 entered promiscuous mode
619:xenbr0: port 1(peth0) entering forwarding state
620-device vif0.0 entered promiscuous mode
621-New device vif0.0 does not support netpoll
622-Disabling netpoll for xenbr0
--
625-hdc: drive_cmd: error=0x04 { AbortedCommand }
626-ide: failed opcode was: 0xec
627:eth0: no IPv6 routers present
628:xenbr0: port 1(peth0) entering disabled state
629:xenbr0: port 1(peth0) entering forwarding state
看了“linux grep命令操作指南”還想看: