Linux commands (while, shell parameter usage), linuxshell
#! /Bin/bash while IFS =: read name1 name2 name3 name4 # IFS is the specified delimiter when reading content from a file: the separate parts are assigned to corresponding variables respectively. do echo $ name1 '|' $ name2 '|' $ name3 '|' $ name4 done <a # the function of anti-quotation marks and $ () is to replace commands, the string in the backquotes or $ () is used as a command for execution. However, the backquotes cannot be followed by backquotes, while $ () can. LS = 'LS' echo $ ls # The single quotes are not parsed at all. All special strings are ignored and output as strings are. LS = 'LS' echo $ ls # Double quotation marks are similar to single quotation marks. The difference is that they are not so strict. Three special characters in double quotation marks cannot be ignored: $ ,\,', that is, the single quotation marks explain the special meaning of the string, and the single quotation marks are used directly. LS = "ls" echo $ LS # However, if you use the eval command, the command in double quotation marks will be interpreted. LS = "ls" eval "$ LS" set -- 1 2 3 4 # set parameters, which are the same as the two parameters in main of c. While [$ #-gt 0] # $ # represents the total number of parameters do echo $1 # output the first parameter shift 1 # subtract 1 from the number of parameters and move one digit to 1, you can also set 2 to move 2 bits at a time, which is equivalent to I --. I is the total number of parameters. Done #-gt is greater than #-lt is less than #-ge is greater than or equal to #-le is less than or equal to #-eq is equal to #-ne is not equal to #$1 can be used in the script, $2... to accept the parameter, but there is another way to accept the parameter, that is, getopts. While getopts abc opt #. /main. sh-a-B-c can specify the parameter and then execute the related command do case $ opt in a) echo "abcd"; B) echo "1234"; c) echo "ABCD"; *) echo "*****"; esac done