I am trying to run a shell code with getopts arguments passing at run time. But below script is throwing "Invalid Argument" error.
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
Can someone help me on this why the script is failing?
Many Thanks in advance.