Windows
Linux
PowerShell Equivalents
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
diff -u old.txt new.txt
diff -u old.txt new.txt
diff -u old.txt new.txt
Overview
What this command does
Shows line-by-line differences or compares two already sorted lists.
Migration tip: Use
diff -u for readable patches. Use comm when both files are sorted and you need unique or shared lines.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 option | Use |
|---|---|
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 |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference 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