This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

修性不修命,萬劫陰靈難入聖; 修命不修性,猶有家財無主柄
Album | Blog | Comment | Profile | Control Panel
aquatower | 10 April,2009 10:23
Bookmark: HemiDemi MyShare Baidu Google Bookmarks Yahoo! My Web Del.icio.us Digg technorati furl Bookmark to:YouPush Bookmark to:你推我報

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
在不符合搜尋字串的行前面,標示行數


Comment

Trackback

Comment Permissions: Only members may comment. If you are not a PIXNET member, click here to sign up.