Laynetworks  
Web laynetworks.com Google
Home | Site Map | Tell a friends
Management Tutorials
Download
Tutorials
History
Computer Science
Networking
OS - Linux and Unix
Source Code
Script & Languages
Protocols
Glossary
IGNOU
Quiz
About Us
Contact Us
Feedback
 
Sign up for our Email Newsletter
 
Get Paid for Your Tech Turorials / Tips

 

 

Home > Source Code > Shell Script
Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Shell Script
 

Shell script sort given list of numbers using bubble sort

clear
echo "Enter the number of numbers :"
read limit
count=1
while [ $count -le $limit ]
do
eval read x$count
count=`expr $count + 1`
done
i=1
while [ $i -le $limit ]
do
eval xval = "\$x$i"
j=`expr $i + 1`
s1=`expr $limit -1`
while [ $j -le $s1 ]
do
eval xval="\$x$j"
k=`expr $j + 1`
eval yval="\$x$k"
if [ $xval -gt $yval ]
then
eval x$j ="$yval"
eval x$k="$xval"
fi
j=`expr $j + 1`
done
i=`expr $i +1`
done
count =1
echo " The sorted array is "
while [ $count -le $limit ]
do
eval echo "\$x$count"
count=`expr $count + 1`
done

 
Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 
Donation | Useful links | Link to Laynetworks.com | Legal | SharePoint Development
Copyright © 2000-2010 Lay Networks All rights reserved.