| Start | ||||
|---|---|---|---|---|
| Sort command output
Input from a file Input from a command You can sort any output command. In the example a list of file following a pattern. |
||||
| Make output unique If each lines of the output need to be unique, add To display owner of files in folder |
||||
| Numeric sort Suppose we have this file: To sort this file numerically, use sort with -n option: This should sort the file as below: Reversing sort order: To reverse the order of the sort use the -r option To reverse the sort order of the above file use: This should sort the file as below: |
||||
| Sort by keys Suppose we have this file: To sort this file using a column as key use the k option: This will sort the file with column 2 as the key: Now if we have to sort the file with a secondary key along with the primary key use: This will first sort the file with column 2 as primary key, and then sort the file with column 1 as secondary key: If we need to sort a file with more than 1 key , then for every -k option we need to specify where the sort ends. So -k1,1 means start the sort at the first column and end sort at first column. -t option In the previous example the file had the default delimeter - tab. In case of sorting a file that has non-default delimeter we need the -t option to specify the delimeter. Suppose we have the file as below: To sort this file as per the second column, use: This will sort the file as below: Syntax
Parameters
RemarksFull user manual of |
Read Article
https://develop.horje.com/learn/1434/reference