1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > linux查看生产日志命令(cat grep tail sed)

linux查看生产日志命令(cat grep tail sed)

时间:2021-09-04 15:23:49

相关推荐

linux查看生产日志命令(cat grep tail sed)

linux查看生产日志命令

1.cat2.grep3.tail4.sed

1.cat

查看log.log前200行

cat log.log | head -n 200

查看test.log倒数200行

cat test.log | tail -n 200

查看test.log中包含http的所有行

cat test.log | grep "http"

查看test.log中包含http的所有行,并显示前后行

cat -n test.log | grep -C 5 “http” (匹配到的前后5行)cat -n test.log | grep -B 5 “http” (前5行)cat -n test.log | grep -A 5 “http” (后5行)

2.grep

查看test.log中包含http的所有行(-i忽略大小写)

grep -i "http" ./test.log

3.tail

实时日志-关键字查询

tail -f test.log | grep "关键字"

查询最新10 条日志

tail -fn 10 test.log

4.sed

SED 查看某时间段日志

sed -n '/-06-02 13:10:30/,/-06-02 13:10:40/p' test.log

某时间端日志输出到指定文件中

sed -n '/-06-02 13:10:30/,/-06-02 13:10:40/p' test.log > test0602.log

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。