---
name: "gendiff"
section: "1"
platform: "linux"
package: "rpm-tools"
version: "6.0.1-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/gendiff"
---

# gendiff(1)

Utility to aid in error-free diff file generation

## NAME

gendiff - Utility to aid in error-free diff file generation

## SYNOPSIS

**gendiff** *DIRECTORY* *DIFF-EXTENSION*

## DESCRIPTION

**gendiff** is a tool for generating a *diff* file from a single directory. The generated *diff* can be applied with the [**patch**(1)](/patch/1.md) program to recreate the changes.

**gendiff** looks for any files with *DIFF-EXTENSION* as their extension in the specified *DIRECTORY*, and runs [**diff**(1)](/diff/1.md) on the files with *DIFF-EXTENSION* and the counterpart without it, in that order. This allows for generating diffs from source code without making a full copy of the directory, which you'd otherwise need when using the [**diff**(1)](/diff/1.md) utility directly.

**gendiff** is commonly used to creating patches for the purposes of packaging software with [**rpmbuild**(1)](/rpmbuild/1.md).

## ARGUMENTS

*DIRECTORY*

The directory to generate a diff from.

*DIFF-EXTENSION*

The diff extension to look for.

## EXIT STATUS

On success, 0 is returned, a nonzero failure code otherwise.

## EXAMPLES

Assuming you need to modify a source file called *somefile.cpp* and have chosen the extension *fix*, copy it to *somefile.cpp.fix* before editing it. Then edit the original file (*somefile.cpp*).

After editing all the files you need to edit in this fashion, enter the directory one level above where the source code resides, and run **gendiff** on it:

```
gendiff myproject-1.0 .fix > myproject-1.0-fix.patch
```

## SEE ALSO

[**diff**(1)](/diff/1.md), [**patch**(1)](/patch/1.md)
