linux统计文件中关键字出现的行号

记录一下,以免自己以后忘:

统计文件中关键字分别出现的哪一行:grep -n "关键字"    “文件路径” | cut -d ":"  -f1

统计文件中关键字出现的最后一行行号:grep -n "关键字"    “文件路径” | tail -n 1 | cut -d ":"  -f1

grep -A 20 "uthor:哪个没注册啊  false"    /opt/datasvc/logs/datasvc.log

grep -A 100 " author:哪个没注册啊"    /opt/datasvc/logs/catalina.out|tail -100

猜你喜欢

转载自m635674608.iteye.com/blog/2214001