{
    "mode": "man",
    "parameter": "lsdiff",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/lsdiff/1/json",
    "generated": "2026-05-30T05:14:29Z",
    "synopsis": "lsdiff [[-n] | [--line-number]] [[-p n] | [--strip-match=n]] [--strip=n] [--addprefix=PREFIX]\n[[-s] | [--status]] [[-E] | [--empty-files-as-removed]] [[-i PATTERN] |\n[--include=PATTERN]] [[-x PATTERN] | [--exclude=PATTERN]] [[-z] | [--decompress]]\n[[-# RANGE] | [--hunks=RANGE]] [--lines=RANGE] [[-FRANGE] | [--files=RANGE]] [[-H] |\n[--with-filename]] [[-h] | [--no-filename]] [[-v] | [--verbose]...] [file...]\nlsdiff {[--help] | [--version] | [--filter ...] | [--grep ...]}",
    "sections": {
        "NAME": {
            "content": "lsdiff - show which files are modified by a patch\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "lsdiff [[-n] | [--line-number]] [[-p n] | [--strip-match=n]] [--strip=n] [--addprefix=PREFIX]\n[[-s] | [--status]] [[-E] | [--empty-files-as-removed]] [[-i PATTERN] |\n[--include=PATTERN]] [[-x PATTERN] | [--exclude=PATTERN]] [[-z] | [--decompress]]\n[[-# RANGE] | [--hunks=RANGE]] [--lines=RANGE] [[-FRANGE] | [--files=RANGE]] [[-H] |\n[--with-filename]] [[-h] | [--no-filename]] [[-v] | [--verbose]...] [file...]\n\nlsdiff {[--help] | [--version] | [--filter ...] | [--grep ...]}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "List the files modified by a patch.\n\nYou can use both unified and context format diffs with this program.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-n --line-number",
                    "content": "Display the line number that each patch begins at. If verbose output is requested (using\n-nv), each hunk of each patch is listed as well.\n\nFor each file that is modified, a line is generated containing the line number of the\nbeginning of the patch, followed by a Tab character, followed by the name of the file\nthat is modified. If -v is given once, following each of these lines will be one line for\neach hunk, consisting of a Tab character, the line number that the hunk begins at,\nanother Tab character, the string “Hunk #”, and the hunk number (starting at 1).\n\nIf the -v is given twice in conjunction with -n (i.e.  -nvv), the format is slightly\ndifferent: hunk-level descriptive text is shown after each hunk number, and the\n--number-files option is enabled.\n",
                    "flag": "-n",
                    "long": "--line-number"
                },
                {
                    "name": "-N --number-files",
                    "content": "File numbers are listed, beginning at 1, before each filename.\n\n-# RANGE, --hunks=RANGE\nOnly list hunks within the specified RANGE. Hunks are numbered from 1, and the range is a\ncomma-separated list of numbers or “first-last” spans, optionally preceded by a modifier\n'x' which inverts the entire range; either the first or the last in the span may be\nomitted to indicate no limit in that direction.\n\n--lines=RANGE\nOnly list hunks that contain lines from the original file that lie within the specified\nRANGE. Lines are numbered from 1, and the range is a comma-separated list of numbers or\n“first-last” spans, optionally preceded by a modifier 'x' which inverts the entire range;\neither the first or the last in the span may be omitted to indicate no limit in that\ndirection.\n",
                    "flag": "-N",
                    "long": "--number-files"
                },
                {
                    "name": "-F --files",
                    "content": "Only list files indicated by the specified RANGE. Files are numbered from 1 in the order\nthey appear in the patch input, and the range is a comma-separated list of numbers or\n“first-last” spans, optionally preceded by a modifier 'x' which inverts the entire range;\neither the first or the last in the span may be omitted to indicate no limit in that\ndirection.\n",
                    "flag": "-F",
                    "long": "--files"
                },
                {
                    "name": "-p --strip-match=",
                    "content": "When matching, ignore the first n components of the pathname.\n\n--strip=n\nRemove the first n components of the pathname before displaying it.\n\n--addprefix=PREFIX\nPrefix the pathname with PREFIX before displaying it.\n",
                    "flag": "-p"
                },
                {
                    "name": "-s --status",
                    "content": "Show file additions, modifications and removals. A file addition is indicated by a “+”, a\nremoval by a “-”, and a modification by a “!”.\n",
                    "flag": "-s",
                    "long": "--status"
                },
                {
                    "name": "-E --empty-files-as-removed",
                    "content": "Treat empty files as absent for the purpose of displaying file additions, modifications\nand removals.\n",
                    "flag": "-E",
                    "long": "--empty-files-as-removed"
                },
                {
                    "name": "-i --include=",
                    "content": "Include only files matching PATTERN.\n",
                    "flag": "-i"
                },
                {
                    "name": "-x --exclude=",
                    "content": "Exclude files matching PATTERN.\n",
                    "flag": "-x"
                },
                {
                    "name": "-z --decompress",
                    "content": "Decompress files with extensions .gz and .bz2.\n",
                    "flag": "-z",
                    "long": "--decompress"
                },
                {
                    "name": "-H --with-filename",
                    "content": "Print the name of the patch file containing each patch.\n",
                    "flag": "-H",
                    "long": "--with-filename"
                },
                {
                    "name": "-h --no-filename",
                    "content": "Suppress the name of the patch file containing each patch.\n",
                    "flag": "-h",
                    "long": "--no-filename"
                },
                {
                    "name": "-v --verbose",
                    "content": "Verbose output.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "--help",
                    "content": "Display a short usage message.\n",
                    "long": "--help"
                },
                {
                    "name": "--version",
                    "content": "Display the version number of lsdiff.\n",
                    "long": "--version"
                },
                {
                    "name": "--filter",
                    "content": "Behave like filterdiff(1) instead.\n",
                    "long": "--filter"
                },
                {
                    "name": "--grep",
                    "content": "Behave like grepdiff(1) instead.\n",
                    "long": "--grep"
                }
            ]
        },
        "SEE ALSO": {
            "content": "filterdiff(1), grepdiff(1), patchview(1)\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To sort the order of touched files in a patch, you can use:\n\nlsdiff patch | sort -u | \\\nxargs -rn1 filterdiff patch -i\n\nTo show only added files in a patch:\n\nlsdiff -s patch | grep '^+' | \\\ncut -c2- | xargs -rn1 filterdiff patch -i\n\nTo show the headers of all file hunks:\n\nlsdiff -n patch | (while read n file\ndo sed -ne \"$n,$(($n+1))p\" patch\ndone)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Tim Waugh <twaugh@redhat.com>\nPackage maintainer\n\n\n\npatchutils                                   23 Jan 2009                                   LSDIFF(1)",
            "subsections": []
        }
    },
    "summary": "lsdiff - show which files are modified by a patch",
    "flags": [
        {
            "flag": "-n",
            "long": "--line-number",
            "arg": null,
            "description": "Display the line number that each patch begins at. If verbose output is requested (using -nv), each hunk of each patch is listed as well. For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab character, followed by the name of the file that is modified. If -v is given once, following each of these lines will be one line for each hunk, consisting of a Tab character, the line number that the hunk begins at, another Tab character, the string “Hunk #”, and the hunk number (starting at 1). If the -v is given twice in conjunction with -n (i.e. -nvv), the format is slightly different: hunk-level descriptive text is shown after each hunk number, and the --number-files option is enabled."
        },
        {
            "flag": "-N",
            "long": "--number-files",
            "arg": null,
            "description": "File numbers are listed, beginning at 1, before each filename. -# RANGE, --hunks=RANGE Only list hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or “first-last” spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. --lines=RANGE Only list hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range is a comma-separated list of numbers or “first-last” spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction."
        },
        {
            "flag": "-F",
            "long": "--files",
            "arg": null,
            "description": "Only list files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or “first-last” spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "When matching, ignore the first n components of the pathname. --strip=n Remove the first n components of the pathname before displaying it. --addprefix=PREFIX Prefix the pathname with PREFIX before displaying it."
        },
        {
            "flag": "-s",
            "long": "--status",
            "arg": null,
            "description": "Show file additions, modifications and removals. A file addition is indicated by a “+”, a removal by a “-”, and a modification by a “!”."
        },
        {
            "flag": "-E",
            "long": "--empty-files-as-removed",
            "arg": null,
            "description": "Treat empty files as absent for the purpose of displaying file additions, modifications and removals."
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": "Include only files matching PATTERN."
        },
        {
            "flag": "-x",
            "long": null,
            "arg": null,
            "description": "Exclude files matching PATTERN."
        },
        {
            "flag": "-z",
            "long": "--decompress",
            "arg": null,
            "description": "Decompress files with extensions .gz and .bz2."
        },
        {
            "flag": "-H",
            "long": "--with-filename",
            "arg": null,
            "description": "Print the name of the patch file containing each patch."
        },
        {
            "flag": "-h",
            "long": "--no-filename",
            "arg": null,
            "description": "Suppress the name of the patch file containing each patch."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "Verbose output."
        },
        {
            "flag": "",
            "long": "--help",
            "arg": null,
            "description": "Display a short usage message."
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Display the version number of lsdiff."
        },
        {
            "flag": "",
            "long": "--filter",
            "arg": null,
            "description": "Behave like filterdiff(1) instead."
        },
        {
            "flag": "",
            "long": "--grep",
            "arg": null,
            "description": "Behave like grepdiff(1) instead."
        }
    ],
    "examples": [
        "To sort the order of touched files in a patch, you can use:",
        "lsdiff patch | sort -u | \\",
        "xargs -rn1 filterdiff patch -i",
        "To show only added files in a patch:",
        "lsdiff -s patch | grep '^+' | \\",
        "cut -c2- | xargs -rn1 filterdiff patch -i",
        "To show the headers of all file hunks:",
        "lsdiff -n patch | (while read n file",
        "do sed -ne \"$n,$(($n+1))p\" patch",
        "done)"
    ],
    "see_also": [
        {
            "name": "filterdiff",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/filterdiff/1/json"
        },
        {
            "name": "grepdiff",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/grepdiff/1/json"
        },
        {
            "name": "patchview",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/patchview/1/json"
        }
    ]
}