#function myfunc
myfunc(){
echo $1
case $1 in e) a=5 ;; q) a=10 ;;
esac
}
myfuncI need help in following :
$myfunc.sh eecho $1 is not showing anything. case is also not working. What am I doing wrong?
1 Answer
You forgot to pass at least one parameter to the myfunc function when you call it. So, your myfunc.sh script should look like:
#!/bin/bash
#function myfunc
myfunc(){ echo $1 case $1 in e) a=5 ;; q) a=10 ;; *) a='not e or q' ;; esac echo $a
}
myfunc $1 #in this case you can also use $@ or $* More about:
1