#!/bin/bash
set -e
cmd="ls"
while getopts :a:t:sn opt; do
case $opt in
a) cmd=$cmd" -a $OPTARG";;
t) cmd="$cmd -t $OPTARG";;
s) cmd="$cmd -s";;
n) cmd="$cmd -n --no-dns";;
*) echo "Invalid param";;
esac
echo $OPTIND
done
echo $cmd
Dev-FandeiMac:tmp code-pc$ ./test.sh -a test1.sh -t hhh -s -n ttss
ls -a test1.sh -t hhh -s -n --no-dns