grep指令用法 grep -i pattern files :不區分大小寫地搜索。預設為區分大小寫, grep -l pattern files :只列出符合字串的檔名, grep -L pattern files :列出不符合字串的檔名 #grep -i 'word' grep.txt --color 搜尋grep.txt裡有word的字串, 並把行數印出 --color: 搜尋的字串標注顏色 (預設是red) 30 black 31 red 32 green 33 yellow 34 blue 35 purple 36 cyan 37 white *變更顏色 #GREP_COLOR= 34 #export GREP_COLOR #grep -i 'word' grep.txt --color 此時標注的顏色就變成blue -n,--line-number 在符合搜尋字串的行前面,標示行數 -n[number] 在符合搜尋字串的行前面,標示行數,並顯示前後number行數 #grep -i -n3 'Large' grep.txt 印出Large所在行, 同時印出前三行及後三行 -v,--revert-match 在不符合搜尋字串的行前面,標示行數
文章標籤
全站熱搜
創作者介紹
創作者 aquatower 的頭像
aquatower

2006隨手札記

aquatower 發表在 痞客邦 留言(0) 人氣(11,563)