linux搜索log文件的内容

1、less## 标题
less -N 日志文件名.log
less -N test.log然后输入"/context"搜索context关键字
点击键盘↑ ↓可以滚动,点击 N 可以查看上一个,n可以查看下一个
**2、tail和head **## 标题
tailf test.log (等同 tail -f test.log) 实时日志
head -n500 test.log 显示top 500行
tail -n500 test.log 显示last 500行
tail -n +500 test.log 从第500行开始显示,显示第500行以后的
3、cat## 标题
cat test.log |grep ‘关键字’ 关键字搜索
4、sed## 标题
sed -n ‘5,15p’ test.log 查看文件的第5行到第15行

你可能感兴趣的:(linux,运维,服务器)