I'm in need to pass arguments to a shell script, which after validation, need to be passed on to a function in the script either as same or after modification.
#!/bin/sh
func1(){
echo "called func1 with $1" ;
exit 0 ;
}
func2(){
echo "called func2 with $1" ;
exit 0 ;
}
if [ $# -eq 0 ]
then
echo "Usage:" ;
echo "script.sh arg1 arg2" ;
exit -1 ;
fi
if [ "$1" -eq "txt1" ]
then
func1 $2 ;
exit 0 ;
fi
if ["$1" -eq "txt2" ]
then
func2 $2 ;
exit 0;
fi
The response I get is
sh script.sh txt1
sh: txt1: bad number
sh: txt1: bad number