grep用法

統計文件中帶有某些關鍵字的行出現的次數 grep+wcspa

grep xxx /var/run/dmesg.boot | wc -lit

-w選項指定要搜索的單詞
test

grep -w 'seven' test.txtimport


搜以特定字符開頭(結尾)的單詞awk

grep '\<seven' test.txtstream

grep 'seven\>' test.txt搜索

搜以特定字符開頭(結尾)的行grep

grep '^seven' test.txtim

grep 'seven$' test.txt統計

顯示目標行的上下文

grep -C 1 twentyseven test.txt

grep -A 1 -B 1

grep "twenty[1-4]" test.txt

不顯示grep

ps -afx | grep ttyv | grep -v grep

ps aux|grep qemu|awk '{print $2}'|xargs kill -9

相關文章
相關標籤/搜索