Linux Tip #4: Simple sort with the sort command

You can easily sort your outputs in Linux using the “sort” command. Simply pipe “|” your output to a “sort” command and you should see the sorted results.

See sample usage below. This is just to start off, I’ve cover more in future posts.

[root@hantu ~]# cat numbers
5
4
3
2
1
0
6
7
8
9

[root@hantu ~]# cat numbers | sort
0
1
2
3
4
5
6
7
8
9

[root@hantu ~]# cat numbers | sort -r
9
8
7
6
5
4
3
2
1
0

Happy sorting!!

Leave a Reply

© 2008-2009 The Danesh Project
Powered by Wordpress and made by Guerrilla. Best viewed in Mozilla Firefox