对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 结束录入

相关内容