Sorting File Contents in Order
Sorting file contents via command line interface.
sort
Definition:
It is used to sort a program or file that is given in its input.
Syntax:
sort [option] filename
Options:
Option | Description |
---|---|
-o | To write the output to a new file. |
-r | To sort in reverse order. |
-n | To sort a file numerically. |
-nr | To sort a file with numeric data in reverse order. |
-k | To sort a table on the basis of any column number. |
-c | To check if the file given is already sorted or not. |
-u | To sort and remove duplicates |
Example:
- To simply sort a file:
sort myfile.txt
Get hands-on with 1400+ tech skills courses.