I'm trying to run an if statement that takes multiple case's
if [ $# -eq 0 or "$1" = '--help' or "$1" = '-h'] ; then
Thats the current cost i'm using I've tried a few different versions but its throwing up errors...
Can if be used with multiple or or statements ?
Also is it possible to have multiple options to point to the same thing in a case statement ?
i.e. instead of --help) I could have -h or --help) something like that ?
Thanks.
awk
2
well, the or option, at least in ksh, should be "-o" NOT "or"
sb008
3
if if [ $# -eq 0 -o "$1" == '--help' -o "$1" == '-h']
then
....
fi
case $1 in
''|'--help'|'-h') ...............
;;
esac
However, "getopts" is meant to parse options
If ksh is being used, this will also work:
if [[ $# = 0 || $1 = ?(--help|-h) ]] ; then