sort Command: Tutorial & Examples
Sort the lines of a file
sort command is a Linux utility that is used to sort the lines of a text file or the output of a command. It is often used in combination with other commands to process and
To use the
sort command, you will need to specify the input file or the command whose output you want to sort. For example, to
sort the contents of a file named
you might use the following command:
This will read the contents of
input.txt and sort the lines alphabetically. The sorted output will be displayed on the command line.
You can also use various options with the
sort command to modify its behavior. For example, you can use the
-r option to sort the lines in reverse order, or the
-n option to
sort the lines numerically.
sort command is a useful tool for processing and analyzing data, and it is available on most Linux distributions. It can be used in combination with other commands, such
awk, to extract and process specific information from a file or the output of a command.