Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须在 unix 中编写脚本。
当我这样称呼它时:
./check -l word1 -c word2,
我需要从脚本内部获取与命令 -l 和 -c 一起使用的单词。
使用getopts如下脚本所示:
getopts
#!/bin/bash while getopts l:c: option do case "$option" in l) loption="$OPTARG" ;; c) coption="$OPTARG" ;; esac done echo "L is: $loption" echo "C is: $coption"