I'm trying to have my getops
function run with multiple flags and arguments but instead of short (-f
style) flag, I want to accept a long one (--flag
style). For example:
if [ $# -lt 1 ]; then
usage >&2
exit 1
else
while $1 "hf:" opt; do
case $opt in
h)
echo "Here is the help menu:"
usage
;;
f)
ls -l $OPTARG >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
:)
echo "Option -$OPTARG requires an argument" >&2
exit 1
;;
esac
done
fi
I would like the -h
and -f
to be --help
and --file
respectively.
How do I do that?