bash - What's the difference between -n and -g in sort? -
this question has answer here:
according man page, -n
option compares "string numerical value", , -g
compares "general numerical value". what's difference between two?
as per source code, here 3 numeric sorts:
- numeric: handle strings of digits optional decimal point, no exponential notation.
- general_numeric: handle numbers in exponential notation, handle hex, infinity, .. (cf man strtold)
- human_numeric: sorting human readable units either si or iec prefixes.
here exemples:
$ sort /tmp/tosort-gen 0 0x0a 1 100 1e1 1e2 1k 1m 2e3 inf $ sort -h /tmp/tosort-gen 0 0x0a inf 1 1e1 1e2 2e3 100 1k 1m $ sort -g /tmp/tosort-gen 0 1 1k 1m 0x0a 1e1 100 1e2 2e3 inf
Comments
Post a Comment