?? echo-params.sh
字號:
#!/bin/bash# echo-params.sh# Call this script with a few command line parameters.# For example:# sh echo-params.sh first second third fourth fifthparams=$# # Number of command-line parameters.param=1 # Start at first command-line param.while [ "$param" -le "$params" ]do echo -n "Command line parameter " echo -n \$$param # Gives only the *name* of variable.# ^^^ # $1, $2, $3, etc. # Why? # \$ escapes the first "$" #+ so it echoes literally, #+ and $param dereferences "$param" . . . #+ . . . as expected. echo -n " = " eval echo \$$param # Gives the *value* of variable.# ^^^^ ^^^ # The "eval" forces the *evaluation* #+ of \$$ #+ as an indirect variable reference.(( param ++ )) # On to the next.doneexit $?# =================================================$ sh echo-params.sh first second third fourth fifthCommand line parameter $1 = firstCommand line parameter $2 = secondCommand line parameter $3 = thirdCommand line parameter $4 = fourthCommand line parameter $5 = fifth
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -