Linux sort command

Linux sort command is used to the output in numeric or alphabetic order.

Example:

Create a file:

[root@localhost k2admin]# cat > k2file.txt
Welcome to k2schools
Welcome to k2schools again and again
Welcome to k2schools
Linux is open source operating system
Linux is open source operating system

Sort the data:

[root@localhost k2admin]# sort k2file.txt
Linux is open source operating system
Linux is open source operating system
Welcome to k2schools
Welcome to k2schools
Welcome to k2schools again and again

To remove duplicate entries from output

[root@localhost k2admin]# sort -u k2file.txt
Linux is open source operating system
Welcome to k2schools
Welcome to k2schools again and again

Powered by k2schools
Skip to toolbar