How to use linux echo command

青灯夜游
Release: 2023-01-07 11:45:44
Original
41537 people have browsed it

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.

How to use linux echo command

#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 [选项] [输出内容]
Copy after login

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 ~]#
Copy after login

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"选项,则在输出内容结束后,不会换行,直接显示新行的提示符
Copy after login

If the "-e" option is used in the echo command, control characters can be supported, as shown in the following table.

##\\Output\self\aOutput warning sound\bBackspace key, which is the left delete key\cSuppress the newline character at the end of the output line. Consistent with the "-n" option\eEsc key\fForm feed character \nLine break\rEnter key\tTab character, which is the Tab key\vVertical tab character\OnnnOutput characters according to the octal ASCII code table. Among them, 0 is the number 0, and nnn is a three-digit octal number \xhh Output characters according to the hexadecimal ASCH code table. Where hh is a two-digit hexadecimal number
Control characters Function
Related recommendations: "

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template