bash$ ./reverse a b c d
d
c
b
a
bash$
x=$* #To set all the arguments in a variable 'x'
c=$# #To set the total number of arguments in variable 'c'
while [ 1 -le $c ]
do
c=`expr $c - 1` #To decrement the variable 'c' by 1
shift $c #To shift the total arguments by count 'c'
echo $1
set $x #To reset the arguments by the previous arguments
done
Can we do this using sed?
for (( i = ${#*}; i > 0; i-- ))
{
echo ${!i}
}