$grep -10 ‘123’ test.log//打印匹配行的前后10行

$grep -C 10 ‘123’ test.log//打印匹配行的前后10行

$ grep -A 10 -B 10 ‘123’ test.log //打印匹配行的前后10行

$grep -A 10 ‘123’ test.log //打印匹配行的后10行

$grep -B 10 ‘123’ test.log//打印匹配行的前10行

其他例子:
//显示既匹配 ‘123’又匹配 ‘456’的行
grep ‘123’ test.log| grep ‘456’

//搜索test.log中满足123的内容的行号
grep -n ‘123’ test.log

//查看test.log指定行号后的内容,比如50行
tail -n +50 test.log

//查看test.log的第50行到100行
sed -n ‘50,100p’ test.log#记得p字母

详细用法可以查考: http://blog.csdn.net/lychbeyond/article/details/41042483

Linux:时间日期指令(date)+查找指令(find,locate,grep)+压缩和解压指令(gzip,gunzip;zip,unzip;tar)(内含详细解释+操作实例)
Linux:时间日期指令(date)+查找指令(find,locate,grep)+压缩和解压指令(gzip,gunzip;zip,unzip;tar)(内含详细解释+操作实例)
linux:2.3.4 查找/搜索命令(find+grep)+压缩/解压缩命令(gzipbzip2+tar+mv+mkdir)
linux:2.3.4 查找/搜索命令(find+grep)+压缩/解压缩命令(gzipbzip2+tar+mv+mkdir)
ceb2Pdf.exe实现ceb文件转pdf,内网离线安装wine(手动编译32位)实现在centos(linux)上运行window程序exe程序,解决wine : Z:\xxx EXE格式无效