Shell Learning 13-shell echo Command

Source: Internet
Author: User
Tags echo command

Echo is an internal command of the shell that prints the specified string on the screen. Command format:
Echo Arg
You can use echo to achieve more complex output format control.
Show escape characters
echo "\" It is a test\ ""
The result will be:
"It is a test"
Double quotes can also be omitted.
Show Variables
Name= "OK" echo "$name It is a test"
The result will be:
OK It is a test
The same double quotation marks can also be omitted.
If the variable is connected to another character, you need to use curly braces ({}):
Mouth=8echo "${mouth}-1-2009"
The result will be:
8-1-2009
Show line breaks
echo "ok!\n" echo "It is a test"
Output:
Ok! It is a test
show No line breaks
echo "Ok!\c" echo "It is a test"
Output:
Ok! It si a test
Show results redirected to file
echo "It is a test" > myfile
output String as-is
If you want to output the string as-is (without escaping), use single quotation marks. For example:
echo ' $name \ '
Show command execution results
Echo ' Date '
The result will show the current date
As can be seen from the above, double quotes are dispensable, single quotes are mainly used in the original output.

Shell Learning 13-shell echo Command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.