grep--常用精选

1、从firefox中提取cookie

grep -oP '"url":"\K[^"]+' $(ls -t ~/.mozilla/firefox/*/sessionstore.js | sed q) 

2、查找忽略大小写

grep -i joe users.txt                # find joe, Joe, JOe, JOE, etc.

3、正则匹配搜索

grep '^fred' /etc/passwd            # find 'fred', but only at the start of a line

grep '[FG]oo' *                      # find Foo or Goo in all files in the current dir

grep '[0-9][0-9][0-9]' *            # find all lines in all files in the current dir with three numbers in a row

4、根据匹配关键字所在行

grep -B5 "the living" gettysburg-address.txt        # show all matches, and five lines before each match

grep -A10 "the living" gettysburg-address.txt      # show all matches, and ten lines after each match

grep -B5 -A5 "the living" gettysburg-address.txt    # five lines before and ten lines after

5、

你可能感兴趣的:(grep--常用精选)