6th linud
Wed Nov 29 2023 07:48:50 GMT+0000 (Coordinated Universal Time)
Saved by
@viinod07
Write a shell script that accepts any number of arguments and prints them in the reverse
order.
Script:
a=$#
echo "Number of arguments are" $a
x=$*
c=$a
res=''
while [ 1 -le $c ]
do
c=`expr $c - 1`
shift $c
res=$res' '$1
set $x
done
echo Arguments in reverse order $res
Output:
sh 1prg.sh a b c
No of arguments are 3
Arguments in reverse order c b a
content_copyCOPY
Comments