shell基础--cat命令的使用

一.cat的常用用法

1.总结

2.实验

(1).非交互式编辑

[root@~_~ day5]# cat > cattest.sh <<STOP

> hello

> STOP

[root@~_~ day5]# cat cattest.sh

hello

[root@~_~ day5]# cat > cattest.sh << EOF

hello cat with EOF

EOF

[root@~_~ day5]# cat cattest.sh

hello cat with EOF

[root@~_~ day5]# cat > cattest.sh <<~_~

> hdhhdhdhhdhd

> ~_~

[root@~_~ day5]# cat cattest.sh

Hdhhdhdhhdhd

 

(2).清空文件内容

[root@~_~ day5]# cat cattest.sh

Hdhhdhdhhdhd

[root@~_~ day5]# cat /dev/null > cattest.sh

[root@~_~ day5]# cat cattest.sh

(3).合并

[root@~_~ day5]# cat > cattest.sh <<EOF

> hello

> EOF

[root@~_~ day5]# cat >  cattest2.sh <<EOF

> world

> EOF

[root@~_~ day5]# cat cattest.sh cattest2.sh >newfile.sh

[root@~_~ day5]# cat newfile.sh

hello

world

 [root@~_~ day5]# cat newfile.sh

hello

world

二.cat命令常用选项

1.总结

 

posted @ 2017-04-17 21:34  ajilisiwei  阅读(12232)  评论(1编辑  收藏  举报