beyes@linux-beyes:~/桌面> grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
beyes@linux-beyes:~/桌面> grep -n root /etc/passwd
34:root:x:0:0:root:/root:/bin/bash
hello world,hehe,are you ok? hello world,are you ok,hehe? world is round. |
beyes@linux-beyes:~/桌面> grep -v -n hehe new-1 //-v 参数是进行过滤
1:
4:world is round.
| root hello-root root,fuck ^root binroot rootnew Root Root123 ROOT |
beyes@linux-beyes:~/桌面> grep root new
root
hello-root
root,fuck
^root
binroot
rootnew
beyes@linux-beyes:~/桌面> grep -i ROOT new
root
hello-root
root,fuck
^root
binroot
rootnew
Root
Root123
ROOT
| root hello-root root,fuck ^root binroot rootnew Root Root123 ROOT |
beyes@linux-beyes:~/桌面> grep -n ^$ new
5:
6:
beyes@linux-beyes:~/桌面> grep -n -v . new
5:
6:
| hello man,is abc ok? hehe,no,def is ok! abcdef ready? abc def can be ok. none null no ABC or DEF no abc or def |
beyes@linux-beyes:~/桌面> grep -F 'abc // F 参数表示用用新行分隔需要匹配的字符串,只要满足其中之一即可
def' new
hello man,is abc ok?
hehe,no,def is ok!
abcdef ready?
abc def can be ok.
no abc or def
beyes@linux-beyes:~/桌面> grep -E 'abc|def' new
hello man,is abc ok?
hehe,no,def is ok!
abcdef ready?
abc def can be ok.
no abc or def
| abc display display abc no abc display def display display def no def display abc def abcdef |
beyes@linux-beyes:~/桌面> grep -E -n '^abc$|^def$' new
7:abc
8:def
beyes@linux-beyes:~/桌面> grep -F -x -n 'abc //参数 -x 表示只能选择完整匹配一行的匹配
def' new
7:abc
8:def
| 欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |