On 28/09/2022 22:13, DrSlony wrote:
Heyprintf '%s\n' "key;foo" "key0;bar0" | sort -Vu -t ';' --key=1,1 sort 8.32 outputs: key;bar key0;foo sort 9.1 outputs: key;foo "key0;foo" is missing.
You're using version sort and '0' is special to version sorting. Specifically as per https://www.debian.org/doc/debian-policy/ch-controlfields.html#version In particular this portion of the documented comparison algorithm: "Then the initial part of the remainder of each string which consists entirely of digit characters is determined. The numerical values of these two parts are compared, and any difference found is returned as the result of the comparison. For these purposes an empty string (which can only occur at the end of one or both version strings being compared) counts as zero." You can see this in the simplified example: # Use --check to see if any matches that need to be dropped: $ printf '%s\n' "key" "key0" | sort -u -C -V || echo equal equal # Here 1 is treated differently: $ printf '%s\n' "key" "key1" | sort -u -c -V && echo different different I agree this is surprising, but version sorting has lots of edge cases, so it's probably best to stick to the documented algorithm here. thanks, Pádraig
