cat的建立、鏈接文件功能實例ide
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