I am want to sort below shown lines in a file numerically. it is not coming as expected.
$ cat test
abc1
abc10
abc2
abc11
abc20
abcd1
abcd10
abcd2
abcd11
abcd20
$
Output:-
$ sort test
abc1
abc10
abc11
abc2
abc20
abcd1
abcd10
abcd11
abcd2
abcd20
$
Output Expected:-
abc1
abc2
abc10
abc11
abc20
abcd1
abcd2
abcd10
abcd11
abcd20
Use sort -V
for alphanumeric sorting where numbers are part of string.
-V, --version-sort natural sort of (version) numbers within text
sort -V test
abc1
abc2
abc10
abc11
abc20
abcd1
abcd2
abcd10
abcd11
abcd20
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