Non recursive shell script that is any number of argument and prints them in reverse order


#!/bin/sh

If [ $# -eq 0 ]

Then exit

Fi

Echo “no of arguments are :$#”

Echo “the arguments are”

Num = 1

For i in “$@”

Do

Echo “argument $num is $i”

Num= `expr $num + 1`

Done

C=$#

Echo “the arguments in reverse order are”

While [ $c ine 0 ]

Do

Eval echo \$$c

C=`expr $c-1`

done

Contributed by:Sri Raksha 

Comments