sort command in linux

sort commandThe sort command arranges lines of text alphabetically or numerically in order.

Output of file

# cat file1
3
4
5
2
1

Use sort command to arrange value in order

# sort file1
1
2
3
4
5

Redirect out of sort command in new file

#  sort file1 > sortoutput

# cat sortoutput
1
2
3
4
5

Arrange value in reverse order

# sort -r file1
5
4
3
2
1

Remove duplicate value from file and arrange in ascending order
File output
# cat newfile
5
4
3
3
2
2
1

#sort -u newfile
1
2
3
4
5

sort command, Marge two file
File2 output, as file1 output mentioned above

# cat file2
4
2
5
6

# sort file1 file2
1
2
2
3
4
4
5
5
6

sort command, Marge two file and remove duplicate entry

# sort -u file1 file2
1
2
3
4
5
6
Share on Google Plus

About Penguin Technology

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

1 comments:

  1. I gathered as much knowledge regarding to the Linux, web sever and database server from your site.Keep on updating with more interesting topic.
    Moreover to recover the lost file from Linux Click on:
    android data recovery review
    launch android data recovery
    backup and restore android apps and data
    android backup app data
    recover lost files
    diskdigger pro file recovery


    ReplyDelete