Shell Syntax One

Source: Internet
Author: User
Tags array definition

See the Shell function notation for reference

/etc/init.d/functions printing information can be called, action function

Local variable use plus local definition

Global variables don't add anything

Need to execute the life using the anti-quote '

Strings typically use double quotes ""

Use single quotation marks as output

Scripts can use SH or bash to execute function script loading without giving execute permission

Function can be added when using. or source definition functions

The best way to echo debug scripts

Set-x in script to enable debug mode

Set +x in script to turn off debug mode

Bashdb Dedicated script debugging tool

md5sum Password Generation tool OpenSSL rand 20 password generation tool

partproble Flush disk partition fdisk disk partition tool, disk greater than 2T unavailable parted disk larger than 2T available

PARTED/DEV/SDB mklabel GPT change disk partition table

MKFS.EXT3/DEV/SDB1 formatting

Hang on some things generally do not put in/etc/fstab, should put in etc/rc.local virtual machine can add hard disk,

7, array definition: The array is represented by parentheses, the elements inside are separated by a space

arry= (var1 var2 var3) or arry[0]=var1

Arry[1]=var2 ARRY[2]=VAR3

Read Array contents:

${arry[*]} or ${arry[@]}

Represents all elements in the call array var1 var2 VAR3 ${arry[1]}

Get Var2 ${arry[0]}

Get var1 .... ${arry[n-1]}

Gets the nth element in the array

8, define a type of variable declare

-I: Treat variables as integers

-R: Read-only variable

-X: The variable is passed to the environment variable by export

-A: Treat variables as arrays

Branch statement if condition; then

DoSomething ... fi

If condition Then

DoSomething ... else

DoSomething ... fi

If condition Then

DoSomething ... elif conditions then

DoSomething ... fi

Case $yn in

1);;

2);;

*) ;;

Esac

Looping statements

While condition do

DoSomething ... done

Until conditions do

DoSomething ...

Done

For condition in Do

DoSomething ...

Done

For ((EXPR1;EXPR2;EXPR3))

Do

Command ... done

Shell Syntax 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.