sorting output of echo


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sorting output of echo
# 1  
Old 03-29-2012
sorting output of echo

can someone please tell me who to sort the numerical output of echo?

Code:
 UIO="8180 0 0 0 0 0 0 0 0 0 0 48240 48240 48240 48240 48240 48240 0 0 0 0 0 0 0 48300 0 0 0 48300" 

echo $UIO | sort -n

This doesn't workk. it does not sort the numbers from smallest to highest. any ideas?
# 2  
Old 03-29-2012
Code:
echo $UIO | tr " " "\n" | sort -n | tr "\n" " "

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 03-29-2012
A slightly different one (only because I needed to do this recently too Smilie)

Code:
printf "%d\n" $UIO | sort -n | xargs

This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Echo's strange output

Hi, Kindly help me to understand the behavior or logic of the below shell command $ echo $!# echo $echo $ $ $ echo !$# echo $# 0 I am using GNU bash, version 3.2.25(1)-release (2 Replies)
Discussion started by: royalibrahim
2 Replies

2. Shell Programming and Scripting

Echo output from command

Hello i am trying to do some calculation from output command for example ls -l if then echo "error" else echo "$" fi its something like this which get strings from output command and try to sum total lines of this string if exceed certain number it display error if not it... (3 Replies)
Discussion started by: mogabr
3 Replies

3. Shell Programming and Scripting

Need help in echo output

Hi All, I have code to get the UUID and capacity for the LUN from CX -arry. I need the output in this format LUN Number UUID Space in MB LUN 238 60:06:01:60:C2:56:11:00:28:36:67:59:11:04:DE:11 122880 But Now iam getting this... (3 Replies)
Discussion started by: ranjancom2000
3 Replies

4. UNIX for Dummies Questions & Answers

Help Needed with Sorting Output

Hi all, I'm using Solaris 10, and need help in sorting the below output from the syslog file in descending rather than ascending order. I would like both the hostname and message columns to be sorted, but right now only the message is sorted and the count column, whose order I would like... (2 Replies)
Discussion started by: wthomas
2 Replies

5. Shell Programming and Scripting

formatting output using echo

i have the following script: while ;do b=${ARRAY2} i=0 while ;do a=${ARRAY1} fin=`echo $a - $b | bc` echo -e "${fin}," >> try ((i++)) ((k++)) done echo -n >> try #add statement to format output here #printf "\t" >> try #echo -e '\t' >> nik ((j++)) echo $j (3 Replies)
Discussion started by: npatwardhan
3 Replies

6. UNIX for Dummies Questions & Answers

sorting cksum output.

Hi guys, I have a service directory with a lot of files in. I have to cksum the whole directory and compare it to a release note document. However the problem I have is the files are listed in different lines when running cksum as they are in the release doc. Therefore cksum shows... (1 Reply)
Discussion started by: Stin
1 Replies

7. Shell Programming and Scripting

Help in sorting echo command

Hi, I have a simple question on bash. If i printed out something like below echo -e $q"\t\t\t"$r"\t\t\t"$s"\t\t\t"$u"\t\t\t" |sort -r >>test.txt It cant able to sort the $q value. I tried on -nr option but still the same. For your info, the $q value is actually a floating point. I would... (3 Replies)
Discussion started by: ahjiefreak
3 Replies

8. Shell Programming and Scripting

weird echo output?

#!/bin/bash INPUT=$1 if then INPUT=0$1 TRACKNUMBER=$INPUT fi TRACKNUMBER=$INPUT echo "Track Number:" $TRACKNUMBER if then echo "File Does Not Exist!: split-track"${TRACKNUMBER}".wav" exit 0 fi CUEFILE="$2" (6 Replies)
Discussion started by: TinCanFury
6 Replies

9. UNIX for Dummies Questions & Answers

What is the output of echo *

Hi all, Kindly let me know the output of echo * command. (4 Replies)
Discussion started by: shailja
4 Replies

10. Shell Programming and Scripting

sorting output

hi, I get an output like uid=user1 gecos=user uid=user2 gecos=admin gecos=sol admin uid=user3 uid=user4 gecos=sol, admin and need it modified to: uid=user1 gecos=user (3 Replies)
Discussion started by: funksen
3 Replies
Login or Register to Ask a Question