15个Linux中的“echo”命令的实际示例

浏览:662 发布日期:2017/05/09 分类:技术分享 关键字: Linux
转载
https://www.howtoing.com/echo-command-in-linux/
echo的语法是:

echo [option(s)] [string(s)]
1.输入文本和显示在标准输出的行

$ echo Howtoing is a community of Linux Nerds
输出以下文本:

Howtoing is a community of Linux Nerds
2.声明一个变量和echo它的价值。 例如,声明x的变量并赋予其值= 10。

$ x=10
回显其值:

$ echo The value of variable x = $x
The value of variable x = 10
注 :Linux中的‘-e’选项作为被反斜杠转义字符的解释。

3.使用选项‘\ B’ -退格与反斜线翻译工作者-e“这消除所有的空间之间。

$ echo -e "Howtoing \bis \ba \bcommunity \bof \bLinux \bNerds"
HowtoingisacommunityofLinuxNerds
4.使用选项的’\ n’ -与退格翻译工作者-e’新线从对待它被用在新行。

$ echo -e "Howtoing \nis \na \ncommunity \nof \nLinux \nNerds"
Howtoing
is
a
community
of
Linux
Nerds
5.使用选项“\ t’ -与退格翻译工作者-e’水平制表有水平制表位。

$ echo -e "Howtoing \tis \ta \tcommunity \tof \tLinux \tNerds"
Howtoing is a community of Linux Nerds
6.如何如何使用选项新行‘\ n’以及水平制表符“\ t”同时进行。

$ echo -e "\n\tHowtoing \n\tis \n\ta \n\tcommunity \n\tof \n\tLinux \n\tNerds"
Howtoing
is
a
community
of
Linux
Nerds
7.使用选项“\ V’ -与退格翻译工作者-e’垂直标签有垂直制表位。

$ echo -e "\vHowtoing \vis \va \vcommunity \vof \vLinux \vNerds"
Howtoing
is
a
community
of
Linux
Nerds
8.如何如何使用选项新行‘\ n’以及垂直标签‘\ V’并举。

$ echo -e "\n\vHowtoing \n\vis \n\va \n\vcommunity \n\vof \n\vLinux \n\vNerds"
Howtoing
is
a
community
of
Linux
Nerds
注意 :使用该选项两次或多次要求我们可以增加一倍的垂直选项卡,水平制表符和新行间距。
最佳答案
评论( 相关
后面还有条评论,点击查看>>