Linux Commands Helper

💬 Your AI-powered Linux assistant

diff Command - Compare Files Line by Line

The diff command is used to compare files line by line. It outputs the differences between two files or directories, making it useful for code review, patch creation, and file comparison.

Syntax

diff [options] file1 file2

Examples

diff file1.txt file2.txt

Show the differences between file1.txt and file2.txt.

diff -u old.c new.c

Show differences in unified format (useful for patches).

diff -r dir1 dir2

Recursively compare two directories.

Notes

  • Use -u for unified diff format, commonly used in patches.
  • Can be combined with grep to filter diff output.
  • For applying differences, use the patch command (if available).

© 2025 Linux Commands Helper. All rights reserved.

This project is under construction. Feedback and contributions are welcome.

Fazier badgeFeatured on Startup Fame