⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 echo-params.sh

📁 Shall高级编程
💻 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 + -