[英]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.