
大家好,又见面了,我是你们的朋友全栈君。
#输出文件末尾行(默认10行),当文件有追加时,会输出后续添加的行,不会中断输出,除非ctrl+c中断 
#-f 即 --follow=file.log
tail -f file.log                               
#输出文件末尾包含关键字的行,当文件有追加时,会输出后续添加的行,不会中断输出,除非ctrl+c中断 
#-f 即 --follow=file.log
tail -f file.log | grep "关键字"                
#输出文件的后100行中包含关键字的行(-n 100 即 --lines=100) 
tail -n 100 file.log | grep "关键字"            
#输出文件的后100行中包含关键字的行和该行的后10行 
tail -n 100 file.log | grep "关键字" -A10      
 #输出文件的后100行中包含关键字的行和该行的前10行 
tail -n 100 file.log | grep "关键字" -B10      
#输出文件的后100行中包含关键字的行和该行的前后10行 
tail -n 100 file.log | grep "关键字" -B10 -A10  发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/135938.html原文链接:https://javaforall.cn