In Linux, the echo command is used to output strings, the syntax is "echo [option] [output content]"; if there is no special meaning in the output content, the original content is output to the screen; if the output content has If there is a special meaning, the output prints its meaning.
#The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.
The echo command is similar to PHP’s echo command, both are used for string output.
The command format is as follows:
# echo [选项] [输出内容]
Options:
-e
: supports backslash controlled character conversion (specific See Table 1)
-n
: Cancel the newline symbol at the end of the line after output (the content will not wrap after output)
In fact, the echo command is very simple. If the output content of the command has no special meaning, the original content is output to the screen; if the output content has a special meaning, the meaning is printed.
[Example 1]
[root@localhost ~]# echo "c.biancheng.net" #echo的内容就会打印到屏幕上 c.biancheng.net [root@localhost ~]#
The echo command is that simple. Whatever content is output, the content will be printed on the screen.
[Example 2]
[root@localhost ~]# echo -n "c.biancheng.net" c.biancheng.net[root@localhost ~]# #如果加入了 "-n"选项,则在输出内容结束后,不会换行,直接显示新行的提示符
If the "-e" option is used in the echo command, control characters can be supported, as shown in the following table.
Control characters | Function |
---|---|
Output\self | |
Output warning sound | |
Backspace key, which is the left delete key | |
Suppress the newline character at the end of the output line. Consistent with the "-n" option | |
Esc key | |
Form feed character | |
Line break | |
Enter key | |
Tab character, which is the Tab key | |
Vertical tab character | |
Output characters according to the octal ASCII code table. Among them, 0 is the number 0, and nnn is a three-digit octal number | |
Output characters according to the hexadecimal ASCH code table. Where hh is a two-digit hexadecimal number |
Linux Video Tutorial"
The above is the detailed content of How to use linux echo command. For more information, please follow other related articles on the PHP Chinese website!