EN
Linux - how to sort alphanumeric strings
5
points
1. Overview
With Linux sort command we can sort with argument -V to sort alphanumeric string.
$ sort -V input_file.txt > output_file_2.txt
2. Sort alphanumeric string example
$ cat input.txt
ABC_2
ABC_11
ABC_1
ABC_12
ABC_22
ABC_5
ABC_3
ABC_21
# simple sort
$ sort input_file.txt > output_file_1.txt
$ cat output_file_1.txt
ABC_1
ABC_11
ABC_12
ABC_2
ABC_21
ABC_22
ABC_3
ABC_5
# sort alphanumeric string with argument -V
$ sort -V input_file.txt > output_file_2.txt
$ cat output_file_2.txt
ABC_1
ABC_2
ABC_3
ABC_5
ABC_11
ABC_12
ABC_21
ABC_22
3. Sort alphanumeric string example with screenshot
