The sort command does what it says — it sorts the lines of a file. An alphabetical sort is the default, as you can see in the second code block that follows. In the third code block, you can see that the -r option has made the alphabetical sort into a reverse sort, sorting the files from 2 to a:
[email protected]:~> cat animals cobra aardvark zebra duck elephant [email protected]:~> sort animals aardvark cobra duck elephant zebra [email protected]:~> sort -r animals zebra elephant duck cobra aardvark
There are many options: the most important are -n (sort numerically) and -u (for unique: skip duplicate lines).
Was this article helpful?