授权文章来源:https://www.toymoban.com/news/detail-513579.html
cd /Users/lion/Downloads/shell-test-demos
chmod u+x *.sh
#!/bin/bash
printHelp() {
echo "-p pic (required) path for pic"
exit 1
}
while getopts 'p:h' OPT; do
case $OPT in
p) path="$OPTARG" ;;
esac
done
# check api_key exists
if [ -z "$path" ]; then
echo "path is empty"
printHelp
fi
echo "path = $path"
文章来源地址https://www.toymoban.com/news/detail-513579.html
到了这里,关于【Shell】自定义传入参数的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!