The sort
command is used to sort a complete file by arranging the records in a specific order. By default, the sort command sorts files assuming that the contents are ASCII characters. The file is sorted line by line, and the blank space is used as the field separator. The following slides will explain the sort command better.
Suppose there exists a "file.txt"
with a few names of the students enrolled in a music class. The sort
command is used to sort all the names in the file.
The file contains these names in the following order:
Wayne
George
Alex
Brandon
Cooper
Tom
To sort these names, run the following code:
sort file.txt