In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the echo command". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the echo command.
The echo command of linux is very common in shell programming, and it is also often used when printing the variable value under the terminal.
The syntax of the echo command is:
Echo [options] [string]
1. Enter a line of text and display it on standard output
$echo Tecmint is a community of Linux Nerds
The following text is output:
Tecmint is a community of Linux Nerds
two。 Output the value of a declared variable
For example, declare the variable x and assign it a value of 10.
$xx 10
Will output its value:
$echo The value of variable x = $xThe value of variable x = 10
3. Use the'* / baked 'option
'- e' followed by' / b 'removes all spaces between characters.
Note: the option'- e' in Linux acts as a translator for the backslash of escaped characters.
$echo-e "Tecmint / bis / ba / bcommunity / bof / bLinux / bNerds" TecmintisacommunityofLinuxNerds
4. Use the'* / nasty 'option
Take the'/ n' guild after'- e'as a new line where you meet.
$echo-e "Tecmint / nis / na / ncommunity / nof / nLinux / nNerds" TecmintisacommunityofLinuxNerds
5. Use the'* / tasking 'option
'- e' followed by' / t' adds a horizontal tab between the spaces.
$echo-e "Tecmint / tis / ta / tcommunity / tof / tLinux / tNerds" Tecmint is a community of Linux Nerds
6. You can also use the newline'/ n' and the horizontal tab'/ t' at the same time
$echo-e "/ n/tTecmint / n/tis / n/ta / n/tcommunity / n/tof / n/tLinux / n/tNerds" Tecmint is a community of Linux Nerds
7. Use the'* / vested 'option
'- e' followed by' / v'is followed by a vertical tab.
$echo-e "/ vTecmint / vis / va / vcommunity / vof / vLinux / vNerds" Tecmint is a community of Linux Nerds
8. You can also use line break'/ n 'and vertical tab' / v'at the same time
$echo-e "/ n/vTecmint / n/vis / n/va / n/vcommunity / n/vof / n/vLinux / n/vNerds" TecmintisacommunityofLinuxNerds
Note: you can use two or more vertical tabs, horizontal tabs and line breaks according to your needs.
9. Use the'* / ringing 'option
'- e' is followed by' / r' to specify the carriage return in the output. (LCTT translation note: characters at the beginning of a line are overwritten)
$echo-e "Tecmint / ris a community of Linux Nerds" is a community of Linux Nerds
10. Use the'* / clocked 'option
The'- e' followed by'/ c' suppresses the characters following the output and does not end up with new lines.
$echo-e "Tecmint is a community / cof Linux Nerds" Tecmint is a community @ tecmint:~$
11. New lines will not be output after echo is finished.
$echo-n "Tecmint is a community of Linux Nerds" Tecmint is a community of Linux Nerds@tecmint:~/Documents$
twelve。 Use the'* / asides' option
A sound warning will be heard when the'/ a 'option is followed by'-e'.
$echo-e "Tecmint is a community of / aLinux Nerds" Tecmint is a community of Linux Nerds
Note: please check your volume settings before you begin.
13. Use the echo command to print all files and folders (an alternative to the ls command)
$echo * 103.odt 103.pdf 104.odt 104.pdf 105.odt 105.pdf 106.odt 106.pdf 107.odt 107.pdf 108a.odt 108.odt 108.pdf 109.odt 109.pdf 110b.odt 110.odt 110.pdf 111.odt 111.pdf 112.odt 112.pdf 113.odt linux-headers-3.16.0-customkernel_1_amd64.deb linux-image-3.16.0-customkernel_1_amd64.deb network.jpeg
14. Print the established file type
For example, let's assume that you want to print all the '.jpeg' files, using the following command.
$echo * .jpegnetwork.jpeg
15.echo can use redirectors to output to a file instead of standard output
$echo "Test Page" > testpage## Check Contentavi@tecmint:~$ cat testpageTest Page
List of echo options
Option description-n does not output the newline character at the end. -e enables backslash escape. / b backspace / / backslash / n new line / r enter / t horizontal tab / v vertical tab thank you for reading, the above is the content of "how to use the echo command", after the study of this article, I believe you have a deeper understanding of how to use the echo command, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.