I have a file with the following lines:
4/3
4/7
3/5
3/6
2/4
When sorting using sort without any arguments, it arranges the lines like you would expect. When using sort -n the output is as follows:
3/5
3/6
4/3
4/7
2/4
I don't understand why this happens.
A way to reproduce it is by adding zero width spaces in front of each line except for 2/4
:
U+200B ZERO WIDTH SPACE [Cf]
The following is a hex string containing said arrangement:
% echo "e2808b342f330ae2808b342f370ae2808b332f350ae2808b332f360a322f340a" \
| xxd -r -p | sort -n
3/5
3/6
4/3
4/7
2/4
I doubt this is the case but maybe there is other non printable characters, you could try with a hex dump:
xxd -p < my_file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.