I have a script file which has some simple commands. I want these commands to be executed based on the input. Ia m good with IF statement also. At the end it has to be based on incoming value. Example
CASE 1 :
Execute some commands where Input value as 1
CASE 2 :
Execute commands where Input value as 2
CASE 3 :
Execute commands where Input value as 3
How we can write a case statement within a script file and pass input to this script file. I need to have only one .sh file. While calling this.sh file, I will pass the number. The number which satisfies the case number the command in that block gets executed. I am currently on AIX version 6.1
#!/bin/bash
if [ $# -lt 1 ]
then
echo "Usage : $0 Input value"
exit
fi
case "$1" in
1) echo "process for input value 1"
echo $1
;;
2) echo "process for input value 2"
echo $1
;;
3) echo "process for input value 3"
echo $1
;;
*) echo "Input $1 is not valid"
;;
esac
---------- Post updated at 05:04 PM ---------- Previous update was at 05:03 PM ----------