使用Linux cat命令

作者: tioced 2014-03-22 10:51:50
以下在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 结束录入。

相关资讯