Windows sort equivalent in Linux
Sorts the lines of a text file or input alphabetically, numerically, or by other criteria.
sort
sort
sort
sort
Overview
What this command does
On Windows, "sort" is used to sort lines of text. On Linux, the closest practical mapping shown here is "sort". Sorts the lines of a text file or input alphabetically, numerically, or by other criteria. This reference is grouped under Text Processing.
Windows → Linux context
What changes when you use this on Linux?
Same name, different environment
The basic command name sort is familiar on both platforms, but Linux path rules, quoting, permissions and available options can still change the result.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read Linux command-line basics.
Practical tasks
Common use cases
Sort lines of text
Sorts the lines of a text file or input alphabetically, numerically, or by other criteria.
sort -r
Reverse order (Z to A)
sort -n
Numeric sort (10 comes after 9)
sort -u
Sort and remove duplicates
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
sort file.txt
sort -r file.txt
sort -n numbers.txt
sort -u file.txt
cat names.txt | sort | uniq
ls -la | sort -k 5 -n
Walkthrough
Examples with explanations
# Windows: sort file.txt
sort file.txt # alphabetical sort
sort -r file.txt # reverse order
sort -n numbers.txt # numeric sort
sort -u file.txt # sort + remove duplicates
# Sort and pipe:
cat names.txt | sort | uniq # unique sorted names
ls -la | sort -k 5 -n # sort dir listing by file size
Reference
Common options and variations
| Command or option | Use |
|---|---|
sort -r | Reverse order (Z to A) |
sort -n | Numeric sort (10 comes after 9) |
sort -u | Sort and remove duplicates |
sort -k 2 | Sort by second column/field |
sort -t ',' -k 2 | Sort CSV by second column |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
Debian/Ubuntu, Fedora and Arch all use "sort" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | sort |
Same command on this distribution. |
| Fedora | same command | sort |
Same command on this distribution. |
| Arch | same command | sort |
Same command on this distribution. |
Keep learning