Exploring sort - Linux Commands

| 2 min read

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

OptionDescription
-b, —ignore-leading-blankIgnore leading blanks
-d, —dictionary-orderConsider only blanks and alphanumeric characters
-f, —ignore-caseFold lower case to upper case characters
-n, —numeric-sortCompare according to string numerical value
-r, —reversereverse 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!