版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_37933685/article/details/86094661
cat 命令用于连接文件并打印到标准输出设备上。主要用于读取文件,拼接文件
准备两个文件的内容如下!
file1
one
one one
one one onefile2
two
two tow
tow tow查看file1
cat file1
cat file2
cat file1 file2- 号的使用
-代表cat要从标准输入读取内容,按ctrl+d结束输入,后面还可以加上其他输入源,比如文件
cat - file1 file2注意: 由于
ctrl+d是我这个连接工具的快捷键 复制,才会出现这个问题。
echo "标准输入" | cat - file1 file2-s 去掉重复空行修改文件 file2
file2
two
two tow
tow tow操作
cat -s file2效果
cat file2 | tr -s '\n'-T改变文件内容file2
file2
two
two tow
tow tow
echo "hello"
printf("hello")
return;操作
cat -T file2效果
-n操作
cat -n file2
ls -l | cat -n