[英]How to get program argument in a Linux shell script when also using getopts?
[英]getopts throwing invalid argument error in linux shell script
我正在尝试在运行时传递带有getopts参数的shell代码。 但是下面的脚本抛出“无效参数”错误。
strt_tim=`date`
while getopts dir:day:size: arg; do
case "$arg" in
dir) dirnm="$OPTARG";;
day) dy="$OPTARG";;
siz) sz="$OPTARG";;
*) echo "Invalid arg";;
esac
done
echo
find $dirnm -mtime -$dy -size +$szM -exec ls -lh \
{} \; | awk '{print $3, $4, $5, $6, $7, $8, $9}'
Executing shell script:
sh delutil.sh -dir /path/of/dir/ -day 10 -siz 100
有人可以帮我解决这个脚本失败的原因吗?
提前谢谢了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.