4/15 Unix Wizards, how would I sort a list like this in numerical order?
I can't figure our the sort syntax. I am not a programmer!
+0.04gb
+0.11gb
+1.98gb
+10.94gb
+17.88gb
+2.72gb
+21.02gb
+3.31gb
\_ The regular "sort -n" will work, except you need to remove the
plus signs first: tr -d + | sort -n --mconst
\_ I am trying to figure out how to sort in that format!
Otherwise I will have to sort and then re-add the plus
sign and that seems lame.
\_ newsflash: you seem lame.
\_ whine whine whine.
\_ OP already said he's not a programmer.
\_ and using unix utilities is not programming.
\-gee maybe we should give an awk test before
giving people sloda accounts.
giving people sloda accounts. obviously "not
programmer" = casual unix user. i've met people
who are technical people who never thought about
the fact you could "grep a web page" by doing
soemthing like lynx -dump | grep, so things
obvious to some arent necessarily immediately
obvious to others.
\_ How about: sort -t "+" +1 -n <filename>
\_ Yeah, as long as the sign's always +, that's simpler.
(You could also do "sort -n +.1".) --mconst
\_ cat file.txt | perl -ne 's/^\+/ /g;print;' | sort -n |
perl -ne 's/^ /+/g;print;'
\_ sed 's/+/ /' file.txt | sort -n | sed 's/^ /+/'
\- those are redarded. learn to use sort, if it is in a shell
script and not already in a perl data structure or some such.
\_ Oh fuck you. Those handle negative numbers too.
\_ so does sort -t + +1 -n <file> | sort -t - +1 -n -s -r
\_ Wow, and I always know what the -s and -t options for
sort do. Not to mention - and +
\_ That's what man pages are for, man. sometimes it
does pay off to reinvestigate old tools.... |