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