Shell Process Control Statements

Source: Internet
Author: User

First, if

Syntax format: If test-d $arg then ... else ... fi

Variable test statements can be simplified with []. Example: test-d $arg equivalent to [-D $arg]. (Note: "Space" ["Space"-D "space"])

For more test commands see: http://www.cnblogs.com/fangwu/p/8422910.html

1. Sample script code

#!/bin/shif [-D $arg]then    echo "This is a folder" Else    echo "This is not a folder" fi

2. Execute script (parameter is/usr)

[Email protected]]# sh hello.sh/usr

3. Implementation results

This is a folder

Second, if Elif

If [-D $arg 1]then ...    elif [-F $arg 2]then ... else .....    Fi

Logic and logic or (-A: Logic with-o: Logical OR)

If [-D $arg 1-a-D $arg 2]

Shell Process Control Statements

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.