In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is a detailed introduction to "how to use Shell echo command". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how to use Shell echo command" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of Xiaobian.
Echo command is the most basic command in linux, but also a very common command, especially when writing shell scripts, may often be used, although echo command is very basic, but the function is still rich.
Shell echo command format:
echo string
You can use echo for more sophisticated output format control.
1. Display normal strings:
echo "It is a test"
The double quotes here can be omitted completely, and the following commands have the same effect as the above example:
echo It is a test
2. Show escape characters
echo "\"It is a test\""
The result will be:
"It is a test"
Similarly, double quotes can be omitted
3. The read command reads a line from standard input and assigns the value of each field of the input line to a shell variable.
#!/ bin/shread nameecho "$name It is a test"
The above code is saved as test.sh, name takes the standard input variable, and the result will be:
[root@www ~]# sh test.shOK #Standard Input OK It is a test #Output
4. Show newlines
echo -e "OK! \n" # -e Open escape echo "It is a test"
Output:
OK! It is a test
5. Show no line breaks
#!/ bin/shecho -e "OK! \c" # -e Open escape\c No newlines echo "It is a test"
Output:
OK! It is a test
6. Show results directed to file
echo "It is a test" > myfile
7. Outputs the string as-is, without escaping or taking variables (in single quotes)
echo '$name\"'
Output:
$name\"
8. Display command execution results
echo `date`
Note: the backquotes are used here, not the single quotes.
The result will show the current date
Thu Jul 24 10:08:46 CST 2014 Read here, this article "Shell echo command how to use" article has been introduced, want to master the knowledge points of this article also need to practice to understand, if you want to know more related content of the article, welcome to pay attention to 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.