|
|
|
The |
|
|
Basic alphabetical sort: |
|
|
Reverse order with -r: |
|
|
Numeric sort with -n: |
|
|
Without -n, numbers sort lexicographically: |
|
|
Human-readable sizes with -h: |
|
|
Sort by specific field with -k: |
|
|
Multiple sort keys: |
|
|
Custom field delimiter with -t: |
|
|
Unique sort with -u: |
|
|
Case-insensitive sort with -f: |
|
|
Check if already sorted with -c: |
|
|
Sort in place with -o (output to same file): |
|
|
Random shuffle with -R (or shuf command): |
|
|
Sort by month names with -M: |
|
|
Version number sort with -V: |
|
|
Stable sort with -s (preserve original order for equal elements): |
|
|
Sort with uniq for frequency counting: |
|
|
Top N results: |
|
|
Parallel sort for large files (GNU sort): sort –parallel=4 largefile.txt |
|
|
External sort (handles files larger than memory): sort automatically uses temp files for large inputs |
|
|
Locale affects sort order: |
|
|
Sort and merge multiple files: |
|
|
Practical examples: |
|
|
Sort IP addresses: |
|
|
Sort by file size: |
|
|
Sort CSV by column: |
|
|
Cleanup |
|