zoukankan      html  css  js  c++  java
  • Linux 150命令之查看文件及内容处理命令 cat tac less head tail cut

    cat 查看文件内容

    1. [root@mysql tmp]# cat 2.txt
    2. 1234

    -n 查看行号

    1. [root@mysql tmp]# cat -n 2.txt
    2.      1 1234
    3.      2 1
    4.      3 2
    5.      4 3
    6.      5 4
    7.      6 5

    tac 倒过来显示文件内容

    1. [root@mysql tmp]# tac 2.txt
    2. 5
    3. 4
    4. 3
    5. 2
    6. 1
    7. 1234

    less 分页显示文件内容

    1. history | less
    2. 87 ls
    3.    88 cd /class
    4.    89 ls
    5.    90 cd 01
    6.    91 ls
    7.    92 vim n
    8.    93 vim number.py
    9.    94 python
    10.    95 ls
    11.    96 vim number.py
    12.    97 vim age.py
    13.    98 python age.py
    14.    99 vim age.py
    15.   100 python age.py
    16.   101 vim age.py
    17.   102 python age.py
    18.   103 vim age.py
    19.   104 python age.py

    head 取文件前几行

    -n* 取文件前*行 默认取10行

    1. [root@mysql tmp]# head -n3 2.txt
    2. 1234
    3. 1
    4. 2

    tail 取文件后几行

    -n* 取文件后*行

    1. [root@mysql tmp]# tail -n2 2.txt
    2. 4
    3. 5

    Cut

    取列

    -d 指定分隔符

    -f 取列

    -f3,5 取第三列和第五列

    -f3-5 取第三列到第五列

    1. [root@mysql tmp]# cat 3.txt
    2. i am love,oldboy and oldgril id
    3. [root@mysql tmp]# cut -d "" -f2,4 3.txt
    4. am and
  • 相关阅读:
    11.tp5常见漏洞
    10.tp3常见漏洞
    1.linux分析排查
    3.docker镜像探究
    1.docker概述
    4.docker常用命令
    2.docker安装
    3.windows分析排查
    9.thinkphp框架模型
    2.win2k8搭建asp网站
  • 原文地址:https://www.cnblogs.com/jksbaduen/p/7834518.html
Copyright © 2011-2022 走看看