Quick Tip
Mastering `diff` with Process Substitution for Inline Comparisons
Challenge: You need to compare two files and see the differences inline without creating temporary files.
The Solution: Utilize bash’s process substitution feature with the `diff` command.
diff <(sort file1.txt) <(sort file2.txt)
Why it works: Process substitution (`<(…)`) creates a named pipe or file descriptor that the `diff` command can read from, allowing it to treat the output of commands (like `sort` in this case) as if they were regular files, effectively comparing their contents inline.
Pro-Tip: You can also use this to compare the output of two different commands directly, for example, to compare the running processes of two different systems.
Linux Tips & Tricks | © ngelinux.com | 4/29/2026
