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

📄 ex33a.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# Using getopt# Try the following when invoking this script:#   sh ex33a.sh -a#   sh ex33a.sh -abc#   sh ex33a.sh -a -b -c#   sh ex33a.sh -d#   sh ex33a.sh -dXYZ#   sh ex33a.sh -d XYZ#   sh ex33a.sh -abcd#   sh ex33a.sh -abcdZ#   sh ex33a.sh -z#   sh ex33a.sh a# Explain the results of each of the above.E_OPTERR=65if [ "$#" -eq 0 ]then   # Script needs at least one command-line argument.  echo "Usage $0 -[options a,b,c]"  exit $E_OPTERRfi  set -- `getopt "abcd:" "$@"`# Sets positional parameters to command-line arguments.# What happens if you use "$*" instead of "$@"?while [ ! -z "$1" ]do  case "$1" in    -a) echo "Option \"a\"";;    -b) echo "Option \"b\"";;    -c) echo "Option \"c\"";;    -d) echo "Option \"d\" $2";;     *) break;;  esac  shiftdone#  It is usually better to use the 'getopts' builtin in a script.#  See "ex33.sh."exit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -