实战演练

  • cat file1 file2 file3...

工作原理

  • cat命令不仅可以读取文件、拼接数据,还能够从标准输入中进行读取。
[root@shaofeng ~]# echo "text" | cat - file.txt
text
hi
[root@shaofeng ~]# echo "text" | cat file.txt
hi

补充内容

  • 摆脱多余的空白行
[root@shaofeng ~]# cat multi_blanks.txt
line 1

line 2



line 3

line 4
[root@shaofeng ~]# cat -s multi_blanks.txt
line 1

line 2

line 3

line 4
  • 将制表符显示为^I
[root@shaofeng ~]# cat -T multi_blanks.txt
line 1

^Iline 2



  line 3

line 4
  • 行号
[root@shaofeng ~]# cat -n multi_blanks.txt
     1  line 1
     2
     3  line 2
     4
     5
     6
     7  line 3
     8
     9  line 4

results matching ""

    No results matching ""