Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use the echo command of linux to output a string or extract the value of a Shell variable

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Today, the editor shares with you the use of linux's echo command to output strings or extract the value of Shell variables. I believe many people don't know much about it. In order to make you understand better, I summarized the following contents for you. Let's look down together. I'm sure you'll get something.

The echo command, which is used to output the extracted value of a string or variable on a terminal device, is one of the most commonly used commands in Linux systems, but the operation is very simple.

People usually extract the value of a variable by adding a $symbol to it, such as $PATH, and then output it with the echo command. Or directly use the echo command to output a string to the screen to give the user a hint.

Syntax format: echo [parameter] [string]

Common parameters:

Reference example

Output a string:

[root@linuxcool ~] # echo "LinuxCool.com"

LinuxCool.com

The extracted value of the output variable:

[root@linuxcool ~] # echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Escape the content so that the function of extracting variable values of the $symbol does not take effect:

[root@linuxcool ~] # echo\ $PATH

$PATH

Import the string information into the file with the output redirector:

[root@linuxcool ~] # echo "It is a test" > linuxcool

Use backquotation marks to execute the command and output the result to the terminal:

[root@linuxcool ~] # echo `date`

Output content with newline characters:

[root@linuxcool ~] # echo-e "a\ nb\ nc" abc

Delete a character from the output and notice that the number 3 disappears:

[root@linuxcool] # echo-e "123\ b456"

12456 on the use of linux's echo command to output strings or extract the value of Shell variables is shared here, I hope that the above content can have a certain reference value for everyone, you can learn to apply. If you like this article, you might as well share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report