Shell Scripting Learning (iii)

Source: Internet
Author: User
Tags echo command

Shell echo Command

Display Normal string:

echo "I am cat_crazy."

Note: The double quotes here can be omitted

Show escape characters:

If you want to output quotes, the * number needs to be escaped to output, as follows

echo \ "I am cat_crazy\"

The output is "I'm cat_crazy."

Note: Quotes need to be escaped to output

Display variables:

Name= "Cat_crazy"

Echo $name

Show line breaks:

Echo-e "Hello \ n" #-e open escape \ n line break

echo "Cat_crazy"

The output is:

Hello

Cat_crazy

Note: There is a blank line in the middle

Show No Line breaks

Echo-e "Hello \c" #-e Open escape \c No Line break

echo "Cat_crazy"

Output Result:

Hello Cat_crazy

Show results directed to a file

echo "Cat_crazy" > MyFile

Note: This results will be saved directly to the MyFile file, the MyFile file if there will be overwritten if there is no create

Output characters as-is, without escaping or taking variables (using single quotes)

echo ' $name \ '

The output is $name \ "

Show command execution results:

echo ' Data '

Output Results January 17, 2017 Tuesday 13:23:35 CST

Note: command to use anti-quote wrapping

Shell Scripting Learning (iii)

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.