I'm using the korn shell and trying to create a case statement from the contents of a file that is changed regularly,
each line of the file has three fields,
eg
track1 202.111.111.111 99
room7 222.111.222.333 76
I'm using awk to select each variable. I've been unable to figure out how to do this
does anyone have any suggestions on?
Kindly make it clear. What is the expected o/p on the above i/p?
Or what are you trying to achieve?
the i/p value is not relevant, all that is required is to make a case statement using the contents of a a file that is regularly changed
case "$var" in
track1)
commands;
;;
room7)
commands;
;;
*)
commands;
;;
esac
One of my highly skilled colleagues has pointed me in the direction of the select statement which is perfect for my requirements
try this:-
while read var1 var2 var3
do
case $var1 in
track1)
echo $var1 $var3 $var2
;;
room7)
commands;
;;
*)
commands;
;;
esac
done < INPUTFILE
my final solution
cat > /var/tmp/list <<EOF
track1 202.111.111.111 99
room7 222.111.222.333 76
EOF
select i in `cat /var/tmp/list | awk '{print $1}`
do
echo `grep $i /var/tmp/list`
done