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

Windows PowerShell Compare-Object equivalent in Linux

Shows line-by-line differences or compares two already sorted lists.

Windows PowerShell Compare-Object
→
Linux equivalents
Debian/Ubuntu same command
diff -u old.txt new.txt
Fedora same command
diff -u old.txt new.txt
Arch same command
diff -u old.txt new.txt

Overview

What this command does

On Windows, "PowerShell Compare-Object" is used to compare text files. On Linux, the closest practical mapping shown here is "diff -u old.txt new.txt". Shows line-by-line differences or compares two already sorted lists. This reference is grouped under PowerShell Equivalents → Text Processing.

Migration tip: Use <code>diff -u</code> for readable patches. Use <code>comm</code> when both files are sorted and you need unique or shared lines.

Windows → Linux context

What changes when you use this on Linux?

Equivalent task, different tool

Windows PowerShell Compare-Object maps to diff -u old.txt new.txt for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.

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

Compare text files

Shows line-by-line differences or compares two already sorted lists.

diff -u old.conf new.conf

Show a unified diff

diff -r folderA folderB

Compare directories recursively

comm -3 <(sort a.txt) <(sort b.txt)

Show lines unique to either list

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

diff -u old.conf new.conf
diff -r folderA folderB
comm -3 <(sort a.txt) <(sort b.txt)

Walkthrough

Examples with explanations

diff -u old.conf new.conf # compare two text files
diff -r folderA folderB # compare two directories
comm -3 <(sort a.txt) <(sort b.txt) # compare sorted lists

Reference

Common options and variations

Command or optionUse
diff -u old.conf new.confShow a unified diff
diff -r folderA folderBCompare directories recursively
comm -3 <(sort a.txt) <(sort b.txt)Show lines unique to either list

Distro differences

Debian/Ubuntu vs Fedora vs Arch

Debian/Ubuntu, Fedora and Arch all use "diff -u old.txt new.txt" 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 diff -u old.txt new.txt Same command on this distribution.
Fedora same command diff -u old.txt new.txt Same command on this distribution.
Arch same command diff -u old.txt new.txt Same command on this distribution.

Keep learning

Related PowerShell Equivalents commands