A detailed explanation of the echo command usage in Linux

Source: Internet
Author: User
Tags echo command echo date


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

\ New Line

\ r Carriage Return

\ 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 tab
[Root@zabbix_agentd ~]# echo-e "111cn.net \twww.111cn.net"
111cn.net www.111cn.net
Vertical Tab-V
[Root@zabbix_agentd ~]# echo-e "111cn.net \vwww.111cn.net"
111cn.net
Www.111cn.net
\b Delete \ previous character
[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"

Multiple colors
[Root@zabbix_agentd ~]# echo-e "\033[31mwww.111cn.net \033[0m"
Www.111cn.net
[Root@zabbix_agentd ~]#
\033[31mwww.111cn.net \033[0m
\033 Color Control character start
3 indicates background color
1m is the foreground color, range 1-7
The character that refers to the color
\033 Color Control character end
0m
Can be separated by the number of: Echo-e "\033[31;1;42;5mwww.111cn.net \033[0m"

-N does not wrap line
[Root@zabbix_agentd ~]# Echo-ne "\033[31;1;42;5mwww.111cn.net \033[0m"
www.111cn.net [Root@zabbix_agentd ~]#

References in the shell
': Strong reference, variable substitution not performed
"": weak reference, able to perform variable substitution
': command substitution, referencing the execution knot of the command
echo Date +%f-%t

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.