Thursday, 19 April 2018

Script to reverse the positional parameter list

#shell script to reverse print the positional parameter list
n=$#
for((i=n-1;i>=0;i--))
do
  arr[$i]=$1
  shift
done

echo ${arr[*]}



OUTPUT

Safi>bash revparam.sh 2 4 6 1 5 7 8 9 10
10 9 8 7 5 1 6 4 2

No comments:

Post a Comment