grep基础必备

 

Regular expression:

数字:[0-9], 使用\d不行

https://www.cyberciti.biz/faq/grep-regular-expressions/

 

 

How can I make grep print the lines below and above each matching line?

https://stackoverflow.com/questions/1072643/how-can-i-make-grep-print-the-lines-below-and-above-each-matching-line

 

Use -B, -A or -C option

grep --help
...
-B, --before-context=NUM  print NUM lines of leading context
-A, --after-context=NUM   print NUM lines of trailing context
-C, --context=NUM         print NUM lines of output context
-NUM                      same as --context=NUM
...

 

egrep "00:[2-9][0-9]:[0-9][0-9]" xxx.txt -A 20 -B 2

 

posted @ 2024-11-04 20:30  profesor  阅读(3)  评论(0编辑  收藏  举报