LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

diffstat

patch file statistics generator

TLDR

Show diff statistics
$ diffstat [patch.diff]
copy
Show from piped diff
$ diff -u [old] [new] | diffstat
copy
Show with specific filename format
$ diffstat -f [0|1|2|3|4] [patch.diff]
copy
Strip path components like patch -p
$ diffstat -p [1] [patch.diff]
copy
Show as a table
$ diffstat -t [patch.diff]
copy
Set histogram output width
$ diffstat -w [80] [patch.diff]
copy

SYNOPSIS

diffstat [options] [file]

DESCRIPTION

diffstat reads output from `diff` (or any unified/context diff, including `git diff`, `svn diff`, `hg diff`, or a `patch` file) and produces a histogram showing insertions, deletions, and modifications per file. It is commonly used to summarize patch size and churn.By default `diffstat` reads from stdin; a file argument reads from that file. Filenames in the header lines drive grouping; the `-p` option strips leading path components the same way as `patch -p`.

PARAMETERS

-C

Strip ANSI color escape sequences before parsing. Useful with colordiff output.
-c
Show concise output with a single histogram code per file: `+` (insert), `-` (delete), `!` (modify).
-D dir
Directory of result files to compute unchanged line counts.
-f format
Filename format: 0=path, 1=name, 2=auto, 3=dir, 4=count.
-l
List filenames only.
-m
Merge insert/delete counts from each chunk to approximate modified lines.
-p num
Strip num leading path components (like `patch -p`).
-S dir
Directory containing original files (before applying diff).
-t
Output as a comma-separated table.
-u
Assume patch was created with old and new files swapped.
-w width
Set output width (histogram is never shorter than 10 columns).

CAVEATS

Histograms are scaled — the width (controlled by `-w`) only sets the maximum bar length, not the absolute number of changes. When running on a diff with both added and removed files, use `-c` for a compact summary. Binary files and empty diffs produce no output.

HISTORY

diffstat was written by Thomas E. Dickey in 1992 as a companion tool to GNU diff. It ships in most Linux distributions in the `diffstat` package.

SEE ALSO

diff(1), patch(1), git-diff(1), colordiff(1)

Copied to clipboard
Kai