lsdiff
Show differences between two diff files
SYNOPSIS
lsdiff [OPTION]... [FILE]
PARAMETERS
-s, --status
Show the status of each file (e.g., '!', '+', '-' for modified, added, or deleted) alongside its name.
-l, --long
Display output in a long format, similar to 'ls -l', for unified diffs. This includes file mode, size, and timestamp if available in the diff headers.
-F FORMAT, --format=FORMAT
Specify the output format using a format string. This allows for customized display of file information, similar to the 'ls --format' option. Common specifiers include '%f' (full filename), '%b' (basename), '%d' (dirname), '%m' (mode), '%s' (size), '%t' (timestamp), '%c' (change type).
--help
Display a help message and exit.
--version
Output version information and exit.
DESCRIPTION
The lsdiff command is a utility from the GNU Diffutils package designed to parse the output of the diff command and extract the names of the files that have been modified, added, or deleted.
It's particularly useful for summarizing changes without needing to read the entire diff content. While diff generates the line-by-line differences between files or directories, lsdiff acts as a parser, allowing users to quickly identify which files are involved in a given patch or change set.
It commonly processes standard unified (-u) or context (-c) diff formats, making it an invaluable tool for scripting, version control analysis, or simply getting a high-level overview of a set of changes.
It does not generate diffs itself; its input is always the output of another diff command, usually piped to its standard input.
CAVEATS
lsdiff is designed to parse standard diff output (unified or context format). It may produce incorrect or unexpected results if the input is not a recognized diff format or is heavily customized.
It does not generate diffs; it only interprets existing diff output.
USAGE EXAMPLES
1. Basic usage to list changed files:
diff -u file1.txt file2.txt | lsdiff
This command will output the names of files that differ between file1.txt and file2.txt.
2. Listing files with their status:
diff -ruN old_dir new_dir | lsdiff -s
This will show files that are modified, added, or deleted between old_dir and new_dir, along with their respective status indicators (e.g., '!', '+', '-').
3. Customizing output format:
diff -u file_a.txt file_b.txt | lsdiff -F '%b (%c)'
This example uses a custom format string to display the base name of the file followed by its change type (e.g., 'file_a.txt (!)').
HISTORY
lsdiff is a part of the GNU Diffutils package, which is a fundamental set of tools for comparing files and directories in Unix-like operating systems. Developed by the GNU Project, it embodies the philosophy of small, focused tools that can be chained together in pipelines to perform more complex tasks. Its development reflects the need for programmatic analysis of change sets, enhancing the utility of the core diff command for scripting and automated workflows.