The file test6.txt contains a list of names which we want to sort into alphabetical order to make it easier to read. You can see the original file contents in this image.
Using the following command, we can display the files contents in alphabetical order.
sort test6.txt
If for some reason we need the contents in reverse alphabetical order then we can use the -r option.
sort test6.txt -r
We can also redirect the output of the sort command to create a new sorted file.
sort {Original File Name} > {New Sorted File Name}
Other options are shown in the table below.
Option | Meaning |
---|---|
-n | Numeric sort |
-c | Check to see if the file is already sorted |
-u | Sort and display with duplicates removed |
-M | Sort by month |
-k | Sort by column number |
-o | Output to separate file |
This Website uses cookies to improve Your experience. Feel free to accept or decline Our use of cookies. If You decline We will still use cookies essential to the workings of this Website but there may be somethings that no longer function correctly for You as the User of the Website. If You object to Us using absolutely essential cookies then Our advice would be to leave this Website now to avoid this continuing to happen. If you continue to use this Website for more than about 30 seconds We will take it to mean You have accepted Our use of cookies and the consent box will disappear automatically. Click to read Our full Privacy Policy.
Name | Domain | Purpose | Expiry | Type |
---|---|---|---|---|
wpl_user_preference | hostingorservers.com | WP GDPR Cookie Consent Preferences | 3 months | HTTP |
Name | Domain | Purpose | Expiry | Type |
---|---|---|---|---|
CLID | www.clarity.ms | --- | 1 year | --- |
_clck | hostingorservers.com | --- | 1 year | --- |
_clsk | hostingorservers.com | --- | 1 days | --- |