linux中echo命令用法詳解

來源:互聯網
上載者:User


echo
If -e is in effect, the following sequences are recognized:

   \\     backslash

   \a     alert (BEL)

   \b     backspace

   \c     produce no further output

   \e     escape

   \f     form feed

   \n     new line

   \r     carriage return

   \t     horizontal tab

   \v     vertical tab

   \0NNN  byte with octal value NNN (1 to 3 digits)

   \xHH   byte with hexadecimal value HH (1 to 2 digits)
echo -e "111cn.net  \nwww.111cn.net "
[root@zabbix_agentd ~]# echo -e "111cn.net  \nwww.111cn.net "
111cn.net
www.111cn.net
[root@zabbix_agentd ~]#

[root@zabbix_agentd ~]# echo -e "111cn.net  \nwww.111cn.net "
111cn.net
www.111cn.net
-t定位字元
[root@zabbix_agentd ~]# echo -e "111cn.net  \twww.111cn.net "
111cn.net  www.111cn.net
垂直定位字元-v
[root@zabbix_agentd ~]# echo -e "111cn.net  \vwww.111cn.net "
111cn.net
www.111cn.net
\b刪除\前一個字元
[root@zabbix_agentd ~]# echo -e "111cn.net  \bwww.111cn.net "
111cn.net www.111cn.net
[root@zabbix_agentd ~]# echo -e "111cn.net  \awww.111cn.net "
111cn.net  www.111cn.net
[root@zabbix_agentd ~]# echo -e "111cn.net  \www.111cn.net "

多種顏色
[root@zabbix_agentd ~]# echo -e "\033[31mwww.111cn.net \033[0m"
www.111cn.net
[root@zabbix_agentd ~]#
\033[31mwww.111cn.net \033[0m
\033顏色控制字元開始
3表示背景色
1m是前景色彩 ,範圍1-7
引用顏色的字元
\033顏色控制符結束
0m
可以用;號隔開在可以這樣:echo -e "\033[31;1;42;5mwww.111cn.net \033[0m"

-n不自動換行
[root@zabbix_agentd ~]# echo -ne "\033[31;1;42;5mwww.111cn.net \033[0m"
www.111cn.net [root@zabbix_agentd ~]#

shell中的引用
‘’:強引用,變數替換不會進行
“”:弱引用,能夠執行變數替換
``:命令替換,引用命令的執行結
echo date +%F-%T

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.