zoukankan      html  css  js  c++  java
  • linux之tail和head的使用

    tail

    基本介绍

      用于显示文件的结尾的内容。在默认情况下,tail命令显示文件的后10行内容

    表达式

      tail [options] [filenames]

    常用参数

    • -c:输出最后N个字节
    • -f:当文件增长时,输出后续添加的数据,当文件不存在时,会立即结束
    • -F:和-f用法基本一致,但是在文件不存在时会继续重试
    • -n:
    • -q:
    • -s:
    • -v:

    基本使用

    • 默认显示最后十行

       命令:tail test.txt

    • 指定显示最后多少行

      命令:

      tail -n5 test1.txt  或
      tail -n 5 test1.txt 或
      tail -5 test1.txt 或
      tail -n -5 test1.txt
    • 从第几行开始显示后面的内容
      命令:tail -n +5 test1.txt 或 tail +5 test1.txt
    • 循环输出新增的内容
      命令:tail -f test1.txt 或tailf test1.txt
    • 循环输出最后多少行
      命令:tail -2f test1.txt
      说明:循环输出最后2行
    • 从第几个字节开始往后输出
      命令:
      tail +5c test1.txt 或
      tail -c +5 test1.txt

    head

    基本介绍

       head 命令可以将一段文本的开头一部分输出到标准输出。默认输出前十行。可以同时操作多个文件

    表达式

    head [-n -k ]... [FILE]...

    常用参数

    • -c:输出多少个字节
    • -n:输出多少行
    • -q:
    • -v:

    基本使用

    •  输出前多少行

      命令:  

      head -n3 test1.txt 或
      head -n 3 test1.txt 或
      head -n +3 test1.txt 或
      head -3 test1.txt
    • 输出除去后面多少行外的内容

      命令:head -n -3 test1.txt

    • 输出前几个字节

      命令:head -c5 test1.txt

  • 相关阅读:
    VIM的强大功能
    BigDecimal.ROUND_HALF_XXX的各种用法
    拒绝服务攻击
    浅谈(接口)测试注意事项四
    jmeter 与 java http
    Xms Xmx PermSize MaxPermSize 区别
    Jquery过滤器
    JQ工具函数运用
    C#扩展方法
    LINQ TO XML基础
  • 原文地址:https://www.cnblogs.com/htyj/p/10278248.html
Copyright © 2011-2022 走看看