cat的创建、连接文件功能实例

cat有创建文件的功能,创建文件后,要以EOF或STOP结束;

[root@kickstart ~]# cat > love.txt << EOF
> i love you
> i love you so much 
> i love you with all my heart
> EOF

注:用EOF退出编辑状态;

[root@kickstart ~]# cat love.txt 
i love you
i love you so much 
i love you with all my heart

cat还可以向已存在的文件追加内容

[root@kickstart ~]# cat >> love.txt << EOF
> I am FishcOil,I love Fish.com.
> I love fishc.com!
> I love China.
> EOF
[root@kickstart ~]# cat love.txt 
i love you
i love you so much 
i love you with all my heart
I am FishcOil,I love Fish.com.
I love fishc.com!
I love China.

cat连接多个文件的内容并且输出到一个新文件中

[root@kickstart ~]# cat hate.txt love.txt > love_hate.txt
[root@kickstart ~]# cat love_hate.txt 
hate i hate you
i love you
i love you so much 
i love you with all my heart
I am FishcOil,I love Fish.com.
I love fishc.com!
I love China.
echo 
[root@ts225 gameinstall]# echo '
> i 
> love 
> you
> i love you so much ' > love.txt
[root@ts225 gameinstall]# cat love.txt 
 
i 
love 
you
i love you so much 

转载于:

https://blog.51cto.com/wjpinrain/937408
https://blog.csdn.net/weixin_34005042/article/details/92862883?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.nonecase

标签: none

添加新评论