• linux 查看命令总结


    1.tail -f -n 200 cat.log

    匹配并计数

    cat  /data/logs/yinhe_main/yinhe_main.2019-07-22.log  |grep  '无效的第三方设备'  |wc -l  

    tail -f /data/service/rdw_api/logs/rdw-main.log

    2、使用less命令

    less all.2018092510.0.log 打开log文件,默认显示100行记录。

    输入/CustGroupListServiceImpl 查找符合条件CustGroupListServiceImpl的记录行;n:下一个搜索到的文件位置、N:上一个搜索到的文件位置、b:向后翻一页、u:向前滚动半页、q:退出命令

    3、使用vim命令(仅查询命令,编辑命令这里不做描述)

    vim all.2018092510.0.log 打开log文件。ctrl+u:向上滚半屏、ctrl+d:向下滚动半屏、ctrl+b:向上滚一屏、ctrl+f:向下滚动一屏;

    输入/CustGroupListServiceImpl,即在文件内查找符合对应字符串的内容,n:下一个匹配项,N:上一个匹配项。shift+q:退出编辑模式,q!:退出vim命令并不保存

    1.查询日志中含有某个关键字的信息
    cat app.log |grep 'error'
    2.查询日志尾部最后10行的日志
    tail -n 10 app.log
    3.查询10行之后的所有日志
    tail -n +10 app.log
    4.查询日志文件中的头10行日志
    head -n 10 app.log
    5.查询日志文件除了最后10行的其他所有日志
    head -n -10 app.log
    6.查询日志中含有某个关键字的信息,显示出行号(在1的基础上修改)
    cat -n app.log |grep 'error'
    7.显示102行,前10行和后10行的日志
    cat -n app.log |tail -n +92|head -n 20
    8.根据日期时间段查询(前提日志总必须打印日期,先通过grep确定是否有该时间点)
    sed -n '/2014-12-17 16:17:20/,/2014-12-17 16:17:36/p' app.log
    9.使用more和less命令(分页查看,使用空格翻页)
    cat -n app.log |grep "error" |more
    10.吧日志保存到文件
    cat -n app.log |grep "error" > temp.txt

    ps ef |grep nginx

    whereis nginx

  • 相关阅读:
    Linux(CentOS)下squid代理服务器配置-五岳之巅
    用类实现二叉树
    django--02 模板的使用
    django --01 helloworld样例入门
    微指数爬虫
    celery_01 _celery安装启动
    python多线程几种方法实现
    crontab问题处理
    python可视化--matplotlib
    python网页爬虫--京东家电版块
  • 原文地址:https://www.cnblogs.com/lvgg/p/10529008.html
Copyright © 2020-2023  润新知