Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community of people that helps each other.

If you think you have some skills to help others

help someone and become a part of our community - List Q & A

Linux - how to sort alphanumeric strings

0 contributions
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

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)

 

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more