1. 程式人生 > >grep 正則

grep 正則

code 顯示 終端 cal clas 過濾 class local abc

-w 精準匹配 只有‘root‘ 這個關鍵字的行

[root@localhost sh]# cat root.sh 
#!/bin/bash

root

[root@localhost sh]# grep -w root root.sh  
root

-q 表示只過濾但不在終端顯示出來

grep -q root  root.sh 

-v 過濾出 不帶 ‘abc‘的行

[root@localhost sh]# cat root.sh 
#!/bin/bash

root

abc
[root@localhost sh]# 
[root@localhost sh]# grep -v 
abc root.sh #!/bin/bash root [root@localhost sh]#

grep 正則