Wednesday, June 6, 2012

Sort hex numbers of different length from the command line? - Stack Overflow

If I have a file of hex numbers of different length e.g.
1F
b
c
How can I sort them from the command line?
Linux solutions are welcome, though I'll be using windows and cygwin or gnuwin32.
Note: I clearly can't use SORT 'cos that will keep them in that order which is wrong.
link|edit

feedback

3 Answers


cat thefile | while read line; do printf "%d %s\n" "0x$line" "$line"; done | sort -n | awk '{print $2}'
This retains the original upper/lower case of the hexadecimal numbers.
link|edit
Was this post useful to you?     

windows - sort hex numbers of different length from the command line? - Stack Overflow:

'via Blog this'

No comments:

Post a Comment