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 
 
love 
you
i love you so much