abhilashm86
May 17th, 2009, 03:51 AM
i just tried to print command arguements in reverse order, but only last arguement i printing, also it is giving some error,
#!/bin/sh
i=$#
while [ $i -gt 0 ]
do
eval echo \$$i
i=`expr $i-1`
done
error is
abhilash@abhilash:~$ sh pgm1.sh a b c
c
[: 1: Illegal number: 3-1
what is actually missing?
in php /$$i is not shown, here it is
#!/bin/sh
i=$#
while [ $i -gt 0 ]
do
eval echo \$$i
i=`expr $i-1`
done
~
#!/bin/sh
i=$#
while [ $i -gt 0 ]
do
eval echo \$$i
i=`expr $i-1`
done
error is
abhilash@abhilash:~$ sh pgm1.sh a b c
c
[: 1: Illegal number: 3-1
what is actually missing?
in php /$$i is not shown, here it is
#!/bin/sh
i=$#
while [ $i -gt 0 ]
do
eval echo \$$i
i=`expr $i-1`
done
~