Tag: Shell expression exists * * * Specify dir DIA statement return result
If condition statement: The IF condition statement is divided into single branch structure, double branch structure, Multi-branch Structure-----------------------------------------------------------------------------single Branch If statement: Determines whether the directory exists and is created automatically if it does not exist. #!/bin/bashdir= "/media/cdrom" if [!-e $DIR]thenmkdir-p $DIRfi Dual-branch If statement: Determines whether the specified host can ping, and gives warning alerts based on the returned results. #!/bin/bashping-c 3-i 0.2-w 3 $ >>/dev/nullif [$?-eq 0]thenecho "Host $ up!" Elsecho "Host $ down!" FI multi-Branch if statement: if [expression];then***************elif [expression];then***************....else***************fi
Shell condition Test Statement if