I would like to sort lines of text according to character code or ASCII code value by command line. I tried the following command line but the result is not what I expected.
# string=" 8888888 >' > Transportation > Temp >temp >TEMP > 99 > Temp > Temporary" # LC_ALL=C echo "$string" | sort ' 8888888 99 temp Temp Temp TEMP Temporary Transportation
To sort according to ASCII code value, the output should look like
99 Temp 8888888 Temporary Temp Transportation ' TEMP temp
Does anyone know how to do that?
Program to Print ASCII ValueThe character is stored in variable c . When %d format string is used, 71 (the ASCII value of G ) is displayed. When %c format string is used, 'G' itself is displayed.
Below are the implementation of both methods: Using ASCII values: ASCII value of uppercase alphabets – 65 to 90. ASCII value of lowercase alphabets – 97 to 122.
You've frobbed the wrong program.
echo "$string" | LC_ALL=C sort
Using $LC_COLLATE
is also acceptable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With