bash 模板:带一个参数的脚本
使用此模板创建带一个参数的 bash/shell 脚本,如果使用错误数量的参数则打印用法消息:
bash_one_arg_template.sh
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage: $0 <filename>"
exit 1
fi
# 注意:参数是 $1
# TODO:在此放置你的代码Check out similar posts by category:
Shell
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow