Shell Script Note one

Source: Internet
Author: User

Single Branch if statement

if judgment condition; then

Statement1

Statement1

...

Fi


Two-branch if statement:

if judgment condition; then

Statement1

....

Else

Statement2

....

Fi


Multi-Branched if statement:

If judging condition 1;then

Statement1

.....

Elif Judging Condition 2;then

Statement2

.....

Elif Judging Condition 3;then

Statement3

.....

Else

Statement4

Fi


Exercise: Write a script

Pass a parameter to the script, enter the parameter as Q, q to exit the script, otherwise the user parameters are displayed;

#!/bin/bash

#

if [$ = ' Q '];

Then

echo "Quit ..."

Exit1

elif [$ = ' Q '];

Then

echo "Quit ..."

Exit2

Else

echo $

Fi


This article is from "Satan Daily" blog, please make sure to keep this source http://satantiantian.blog.51cto.com/6159537/1569696

Shell Script Note one

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.