Operating System - Tru64 Unix
1830045 Members
15266 Online
109998 Solutions
New Discussion

Tru64 shell script

 
SOLVED
Go to solution
Dafnis Tejera
Occasional Contributor

Tru64 shell script

Hello to everybody !!!
I'm making a shell script and I have de difficult.

In a case statement I used:

case $REPLY in

[1-$var] ) list ;;


so, when $var is greater than 9 then patter [1-$var] ) is not replace how I like.

for example when $var=12

[1-12] ) patter is how [1-1] )

helme please
2 REPLIES 2
Ivan Ferreira
Honored Contributor

Re: Tru64 shell script

The range goes between 0 and 9, so, if you want to test a two digit number, you need something like:


[0-$var] ) list ;;

[0-9][0-$var] ) list ;;
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ivan Ferreira
Honored Contributor
Solution

Re: Tru64 shell script

In fact, the above is wrong, it should be:

[0-$var] ) list ;;

[0-9][0-9] ) list ;;

Anyway, you can use:

if [ $REPLY -ge 1 ] && [ $REPLY -le $var ]; then
echo "The value is in the range 1-12"
list
fi
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?