Thursday, June 14, 2012
8:26 AM

Shell Script to Sort Number in Descending Order


Q. How do I write Shell Script to print number in descending order
Ans:

#!/bin/bash
echo "enter maximum number"
read n
# taking input from user
echo "enter  Numbers in array:"
for (( i = 0; i < $n; i++ ))
do
read nos[$i]
done
#printing the number before sorting
echo "  Numbers in an array are:"
for (( i = 0; i < $n; i++ ))
do
echo ${nos[$i]}
done
# Now do the Sorting of numbers
for (( i = 0; i

0 comments:

Post a Comment