I have a shell script to build components of a product. The follow snippet will explain what I am doing.
# !/bin/sh
for choice in "$@" ;
do
case $choice in
"o") echo "Calling $choice" ; o ;;
"i") echo "Calling $choice" ; i ;;
"w") echo "Calling $choice" ; w ;;
"m") echo "Calling $choice" ; m ;;
"all") o ; i ; w ; m ; ftp ;;
*) usage ;;
esac
done
Now when I call the script I call it in the following manner: sh build.sh i o w m
What I plan to do is take the input as a single argument containing the required components; sh build.sh iowm
Is there anyway to extract the individual charaters from the input string. And then check for i/w/o/m and then carry on with the build.
Also is there a way to check for 0 arguments using $@ . Currently I use
if test $# = 0
Thanks for the solution. That extracts the first character. Is there anyway I can search for a character in the input string. For eg. if the input string is iowm, I need to search for the character o in the string. Something like grep on a charatcer string rather than a file.