学习老男孩Linux的笔记总结2-【第55课】55-不断补充echo用法的笔记

用法一:在控制台上显示普通的字符串。

[root@localhost ~]# echo "This is example"

This is example

[root@localhost ~]# echo This is example   //输入内容没有“”也是可以的。下同

This is example

 

用法二:配合>”重定向,将单行或者多行的文本插入到文件结尾。

1.[root@localhost ~]# touch demon.txt

[root@localhost ~]# cat demon.txt

[root@localhost ~]# echo "example"> demon.txt

[root@localhost ~]# cat demon.txt

example

2.注意:如果文件里面有内容将被覆盖。

[root@localhost ~]# cat demon.txt

This is old example

[root@localhost ~]# echo This is new example > demon.txt

[root@localhost ~]# cat demon.txt

This is new example

 

用法三:配合>>>”重定向,表示追加。不会覆盖已有文件内容。

[root@localhost ~]# cat demon.txt

This is new example

[root@localhost ~]# echo This second example >> demon.txt

[root@localhost ~]# cat demon.txt

This is new example

This second example

 

 

(这仅仅是每节课后的学习笔记,如果有相关内容将会不断补充)

posted on 2019-05-02 20:57  Erica程  阅读(91)  评论(0)    收藏  举报

导航