In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use the echo command in Shell". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn how to use the echo command in Shell.
Shell's echo instruction is similar to PHP's echo instruction in that it is used for string output.
Shell echo command format:
Echo string
You can use echo for more complex output format control.
1. Display normal strings:
Echo "It is a test"
The double quotation marks here can be omitted, and the following command has the same effect as the above example:
Echo It is a test
two。 Show escape characters
Echo "\" It is a test\ ""
The result will be:
"It is a test"
Similarly, double quotation marks can also be omitted
3. Display variable
The read command reads a row from the standard input and assigns the value of each field of the input line to the shell variable
#! / bin/shread name echo "$name It is a test"
The above code is saved as a variable that test.sh,name receives standard input, and the result will be:
[root@www ~] # sh test.shOK # Standard input OK It is a test # output
4. Show line feeds
Echo-e "OK!\ n" #-e enables escape of echo "It is a test"
Output result:
OK!It is a test
5. Show no line wrapping
#! / bin/shecho-e "OK!\ c" #-e enable escape\ c do not wrap echo "It is a test"
Output result:
OK! It is a test
6. Display results directed to file
Echo "It is a test" > myfile
7. Output strings as is, without escaping or fetching variables (in single quotes)
Echo'$name\ "'
Output result:
$name\ "
8. Display the result of command execution
Echo `date`
Note: backquotation marks are used here instead of single quotation marks.
The result will show the current date
Thu Jul 24 10:08:46 CST 2014 is all the contents of this article entitled "how to use echo commands in Shell". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.