Shell Script (iii)

Source: Internet
Author: User
Tags echo command

Excerpt from: Rookie Tutorial http://www.runoob.com/linux/linux-shell-echo.html

Shell command

1. Echo command

String output

echo "ok! \c "

echo "It is a test"

Output: ok! It is a test

2. printf command

Formatted output

%d%s%f

Escape sequence:

\a: Warning Character

\b: Back

\c: Suppresses (does not display) the newline character at any end of the output (only valid in the parameter string under the%B format designator control), and any characters left in the argument, any subsequent arguments, and any characters left in the format string are ignored

\f: Page Change

\ n: Line break

\ r: Enter

\ t: Horizontal tab

\v: Vertical tab

\ \: Backslash character

\ddd:1 to 3-bit octal value character, valid only in format string

\0DDD: An octal value character that represents 1 to 3

3. Test command

Check if a condition is true and you can test arrays, characters, and files

Such as:

NUM1=

num2=

If test $[num1] -eq $[num2]

< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" >then

< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" > echo ' two numbers equal! '

< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" >else

< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" > echo ' two numbers are not equal! '

< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" >fi

< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" >< Span class= "PLN" > output: two numbers equal!

For specific parameters see: http://www.runoob.com/linux/linux-shell-test.html

Shell Script (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.