Languages
[Edit]
EN

Linux - how to sort alphanumeric strings

5 points
Created by:
Kate_C
19810

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

Screenshot of Linux sort command - sort vs sort alphanumeric string - sort -V - https://dirask.com/q/9pYmzp
Screenshot of Linux sort command - sort vs sort alphanumeric string (sort -V)

 

Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join