← All commands
Topic hub Text Processing
Windows Linux Text Processing Expanded guide

Windows sort equivalent in Linux

Sorts the lines of a text file or input alphabetically, numerically, or by other criteria.

Windows sort
→
Linux equivalents
Debian/Ubuntu same command
sort
Fedora same command
sort
Arch same command
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.

Migration tip: Linux <code>sort</code> is much more powerful than Windows. Combine with <code>uniq</code> to remove duplicate lines.

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.

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 optionUse
sort -rReverse order (Z to A)
sort -nNumeric sort (10 comes after 9)
sort -uSort and remove duplicates
sort -k 2Sort by second column/field
sort -t ',' -k 2Sort 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.

DistributionPackage manager / baseEquivalent commandDifference 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

Related Text Processing commands