- 输出指定信息,常用两选项:
- -n输出后不换行
- -e输出后转义字符(*)才有特殊的含义
$ echo Echo is used to display text
$ x=10
$ echo the value of x is $x
$ echo -e "Tecmint \bis \ba \bcommunity \bof \bLinux \bNerds"
TecmintisacommunityofLinuxNerds
$ echo -e "Tecmint \nis \na \ncommunity \nof \nLinux \nNerds"
Tecmint
is
a
community
of
Linux
Nerds
$ echo -e "Tecmint \tis \ta \tcommunity \tof \tLinux \tNerds"
Tecmint is a community of Linux Nerds
- ‘\r’+’-e’ \r 前的字符不输出
- ‘\c’+’-e’ \c 后的字符不输出,输出完成以后不换行
$ echo -e "Tecmint \ris a community of Linux Nerds"
is a community of Linux Nerds
- echo把内容输出到文件中而不是标准输出(在windows dos中,这种用法会导致空格的出现,但是linux中没有)
echo "hello world">test1.tmp