What about changed files?

095

When using the diff -r command to compare two directories, it also identifies and reports changed files. If a file exists in both directories but has different content, diff will display the differences between those files.

Output for Changed Files:

  • For files that exist in both directories but have been modified, diff will show the differences in a unified or context format, depending on the options used.
  • The output will typically include the lines that have been added, removed, or changed.

Example:

Assuming you have the following directories:

  • dir1/ contains:

    • file1.txt (with content "Hello World")
  • dir2/ contains:

    • file1.txt (with content "Hello Universe")

Running the command:

diff -r dir1/ dir2/

The output might look like this:

diff -r dir1/file1.txt dir2/file1.txt
1c1
< Hello World
---
> Hello Universe

This output indicates that file1.txt has changed between the two directories, showing the specific lines that differ. The < symbol indicates the content from dir1, and the > symbol indicates the content from dir2.

0 Comments

no data
Be the first to share your comment!