Shell note control structure if statement: Shell code #! /Bin/bash www.2cto.com # if statement format: # Put if and then in different rows, and align the fi required for else and end with them horizontally if ["$ {1}" = ''] then echo no argument input. else echo first argument is: $1 fi var = 2 echo "$ {var}" if ["$ {var}" = "1"] then echo one. elif ["$ {var}" = "2"] then echo two. elif ["$ {var}" = "3"] then echo three. else echo at least four. fi for loop: Shell code #! /Bin/bash # The in keyword is followed by a word list, for x in one two three four do echo number $ x done for var in "$ @" do echo you pass in $ var done # use the File wildcard for myfile in/etc/r * do if [-d "$ myfile"] then echo "$ myfile is dir" else echo "$ myfile" fi done # You can also use multiple wildcards in the word list, even the variable # can use relative paths or absolute paths. For relative paths, bash executes wildcard extension relative to the current working directory. Www.2cto.com for x in./* var/lo */home/$ {USER}/* do echo $ x done while and until loop: Shell code #! /Bin/bash echo use while loop control. myvar = 0 while [$ myvar-ne 10] do echo $ myvar = $ ($ myvar + 1) done www.2cto.com echo use until loop control. myvar = 10 until [$ myvar-eq 0] do echo $ myvar = $ ($ myvar-1) done