Here are some other common options for the sort command:
-
-b: Ignore leading blanks when sorting.sort -b input_file.txt -
-f: Ignore case when sorting (case-insensitive sort).sort -f input_file.txt -
-c: Check if the input is already sorted. It will not produce output but will return an exit status.sort -c input_file.txt -
-u: Suppress duplicate lines, only outputting unique lines.sort -u input_file.txt -
-o FILE: Write the sorted output to the specified file instead of standard output.sort -o sorted_output.txt input_file.txt -
-m: Merge already sorted files. This option assumes that the input files are already sorted.sort -m file1.txt file2.txt -
-V: Sort version numbers (e.g.,1.2,1.10,2.0).sort -V input_file.txt -
-S SIZE: Specify the amount of memory to use for sorting. For example,-S 50%uses 50% of available memory.sort -S 50% input_file.txt -
--reverse: An alternative to-r, this option also sorts in reverse order.sort --reverse input_file.txt -
--key=KEYDEF: An alternative way to specify sorting keys, similar to-k.sort --key=2,2 input_file.txt
These options can be combined to customize the sorting behavior according to your needs. For example, you can sort numerically while ignoring case and suppressing duplicates:
sort -n -f -u input_file.txt
