Comment on Tutorial - Sort numbers using arrays in Shell Script By Vivek G



Comment Added by : shruthi

Comment Added at : 2013-01-18 06:00:08

Comment on Tutorial : Sort numbers using arrays in Shell Script By Vivek G
This will give the output check it out

nos=( 2 4 1 30 23 )
echo "Original Numbers in array:"
for ((i = 0; i <= 4 ; i++ ))
do

echo " ${nos[i]} "
done


for (( i = 0; i <= 4 ; i++ ))
do
for (( j = $i; j <= 4; j++ ))
do
if [ ${nos[i]} -gt ${nos[j]} ]; then
t=${nos[i]}
nos[i]=${nos[j]}
nos[j]=$t
fi
done
done

echo -e "\nSorted Numbers in Ascending Order:"
for (( i=0; i <= 4; i++ ))
do
echo "${nos[i]}"
done


View Tutorial



Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Thanks for the tips.

I hesitated to

View Tutorial          By: Dick at 2011-10-09 15:21:50

2. ma'am aiza teaches us very well.. >< i like
View Tutorial          By: chai at 2011-02-07 07:06:36

3. thxs
View Tutorial          By: uhhhhh........... at 2009-01-19 06:55:59

4. Great details you provided here, very straight for
View Tutorial          By: Jackie Wong at 2010-02-05 10:52:25

5. Hi i copied the same code n change the comport no
View Tutorial          By: Nidhi Puri at 2010-12-04 00:55:29

6. Thanks for posting this :)
Being a noobie @

View Tutorial          By: C at 2008-06-23 18:17:26

7. a pretty good site for learners
View Tutorial          By: chaitra at 2011-12-15 10:09:14

8. so if you then wanted to send this gzencoded data
View Tutorial          By: Mike at 2009-03-18 12:12:28

9. hai, i tried the abvoe code, m getting the follwin
View Tutorial          By: charan at 2011-10-20 12:59:59

10. Great Description. Helped a lot.
View Tutorial          By: Dee2019nc at 2009-11-08 18:26:22