红联Linux门户
Linux帮助

使用Linux cat命令

发布时间:2014-03-22 10:51:50来源:红联作者:tioced
以下在Linux命令行中cat命令的使用技巧。

1. 查看文件内容,并在每行前面加上行号
[root@rehat root]# cat -n test.txt

2. 查看文件内容,在不是空行的前面加上行号
[root@rehat root]# cat -b test.txt

3. 合并两个文件的内容
[root@rehat root]# cat test1.txt test2.txt > test_new.txt

4. 全并两具文件的内容,并追回到一个文件
[root@rehat root]# cat test1.txt test2.txt >> test_total.txt

5. 清空某个文件的内容
[root@rehat root]# cat /dev/null > test.txt

6. 创建一个新的文件
[root@rehat root]# cat > new.txt 按 CTRL + C 结束录入。
文章评论

共有 3 条评论

  1. 小孩一个 于 2017-09-20 10:15:03发表:

    谢谢分享,楼主辛苦了!

  2. holy8158276 于 2015-01-21 15:42:18发表:

    感谢分享,学习下。

  3. Shah 于 2014-12-14 14:54:14发表:

    good