Watch this course video
4 minutes
Sort command sort the contents of text file line by line. Sort is a Linux program used for printing lines of input text files and concatenation of all files in sorted order. Sort command takes blank space as field separator and entire Input file as sort key. It is important to notice that sort command don’t actually sort the files but only print the sorted output, until your redirect the output.
Syntax :-
#sort [OPTIONS] [FILENAME]
Sort Command Options:-
-r :- Reverse Sorting
-n :- Sorts numerically
-f :- Case Insensitive Sorting
-c :- To check that whether a text file is sorted or not.
-u :- To remove the duplicate lines from sorted output
-k :- To Sort on a column or word positions in lines of Text file.