What is the sort Command in Linux?
The sort
command in Linux is a powerful utility that sorts the lines of text files or standard input and outputs the sorted lines. It is commonly used to organize data in alphabetical, numerical, or reverse order, making it easier to analyze and process.
Basic syntax:
sort [option] [file]
Sort a file alphabetically:
sort file-name
Options
Option | Description |
---|---|
-b, —ignore-leading-blank | Ignore leading blanks |
-d, —dictionary-order | Consider only blanks and alphanumeric characters |
-f, —ignore-case | Fold lower case to upper case characters |
-n, —numeric-sort | Compare according to string numerical value |
-r, —reverse | reverse the result of comparisons |
Additional Help
You can explore more by using the commands:
sort --help
# or
man sort
Thank you!
Thank you for your time and for reading this!