zoukankan      html  css  js  c++  java
  • linux 日志文件查看

    记录下日志中常用的日志查看命令。

    1.  tail -n 10 -f  **.log

    显示日志文件尾部10行日志,当有新日志产生,会追加显示。

    2. tail 命令

    现ff.sh中有如下信息:

    复制代码
    [root@hxjk_test_backend_services test]# cat ff.sh
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    复制代码

    tail -n 5 ff.sh 显示文件后5行日志和tail -n  -5 ff.sh效果一样

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [root@hxjk_test_backend_services test]# tail -n 5 ff.sh
    15
    16
    17
    18
    19
    [root@hxjk_test_backend_services test]# tail -n -5 ff.sh
    15
    16
    17
    18
    19
    [root@hxjk_test_backend_services test]#

    tail -n  +5 ff.sh 显示的是第5行开始到底部的日志

    复制代码
    [root@hxjk_test_backend_services test]# tail -n +5 ff.sh
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    [root@hxjk_test_backend_services test]# 
    复制代码

    3. head 命令

    head -n 5 ff.sh 显示前5行日志 和head -n +5 ff.sh 效果一样

    复制代码
    [root@hxjk_test_backend_services test]# head -n 5 ff.sh
    1
    2
    3
    4
    5
    [root@hxjk_test_backend_services test]# head -n +5 ff.sh
    1
    2
    3
    4
    5
    [root@hxjk_test_backend_services test]# 
    复制代码

    head -n -5 ff.sh 显示后5行到头的所有信息

    复制代码
    [root@hxjk_test_backend_services test]# head -n -5 ff.sh
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    [root@hxjk_test_backend_services test]# 
    复制代码

    4. cat tail head 命令相结合

    现在若有显示第10行前后5条数据,可如下查询

    复制代码
    [root@hxjk_test_backend_services test]# cat -n ff.sh|tail -n +5|head -n 11
         5    5
         6    6
         7    7
         8    8
         9    9
        10    10
        11    11
        12    12
        13    13
        14    14
        15    15
    [root@hxjk_test_backend_services test]# 
    复制代码

    所以在实际使用中若要查询日志文件中报错信息时,可先通过grep查询出报错信息的行号,再通过上诉命令查询。

  • 相关阅读:
    Emiller's Advanced Topics In Nginx Module Development
    关于使用UDP(TCP)跨局域网,NAT穿透的心得
    linux pipe
    使用Trinity拼接以及分析差异表达一个小例子
    Bowtie2的安装与使用
    使用Tophat+cufflinks分析差异表达
    RNA-seq流程需要进化啦!
    HISAT2+StringTie+Ballgown安装及使用流程
    HISAT2,StringTie,Ballgown处理转录组数据
    p值还是 FDR ?
  • 原文地址:https://www.cnblogs.com/wz123/p/12669478.html
Copyright © 2011-2022 走看看