gendiff - Linux


gendiff is a command-line tool for generating diff reports between two files or directories. It highlights the changes between the provided input, making it essential for code reviews, configuration management, and file comparisons.


gendiff [OPTIONS] <path1> <path2>


  • -f, –format : Specify the output format of the diff report. Available formats include quick, json, yaml, text, and plain. (Default: quick)
  • -r, –recursive: Recursively compare directories and their contents.
  • –dirs-only: Only compare directories and ignore file contents.
  • –add-delete: Show additions and deletions in the diff report.
  • –machine-readable: Print the diff report in a machine-readable JSON format.
  • -h, –help: Display the help message and exit.
  • -V, –version: Show the program’s version and exit.


  • Quick comparison of two files:
gendiff file1.txt file2.txt
  • Recursive comparison of two directories:
gendiff -r directory1 directory2
  • JSON-formatted report showing additions and deletions:
gendiff --machine-readable --add-delete file1.json file2.json

Common Issues

  • Missing files: Ensure that both input paths exist and are accessible.
  • Empty diff reports: If the inputs are identical, gendiff will not generate a diff report.
  • Formatting errors: If the --format option is not set correctly, the report may not be readable.


gendiff can be integrated with other tools:

  • git diff: Generate a visual diff report for git commits.
    git diff | gendiff -f json
  • rsync: Perform a dry run and generate a diff report for a potential file transfer.
    rsync -n source_dir target_dir | gendiff -f text

Related Commands

  • diff
  • cmp
  • pddiff