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、

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容