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

相关文章:

  • 2021-09-18
  • 2021-06-30
  • 2021-11-28
  • 2022-12-23
  • 2021-06-02
  • 2021-08-03
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-07-18
  • 2021-11-04
  • 2022-01-06
  • 2021-07-29
  • 2022-01-07
  • 2021-07-09
相关资源
相似解决方案