Linux合入patch命令,【整理】Linux命令patch的用法

【背景】

折腾:

期间,以为搞懂了patch,实际上对patch的用法还不是很清楚。

此处想要彻底搞清楚-R的含义。

【折腾过程】

1.参看help:CLi@PC-CLI-1 ~/develop/buildroot/diff_patch

$ patch --help

Usage: patch [OPTION]... [ORIGFILE [PATCHFILE]]

Input options:

-p NUM --strip=NUM Strip NUM leading components from file names.

-F LINES --fuzz LINES Set the fuzz factor to LINES for inexact matching.

-l --ignore-whitespace Ignore white space changes between patch and input.

-c --context Interpret the patch as a context difference.

-e --ed Interpret the patch as an ed script.

-n --normal Interpret the patch as a normal difference.

-u --unified Interpret the patch as a unified difference.

-N --forward Ignore patches that appear to be reversed or already applied.

-R --reverse Assume patches were created with old and new files swapped.

-i PATCHFILE --input=PATCHFILE Read patch from PATCHFILE instead of stdin.

Output options:

-o FILE --output=FILE Output patched files to FILE.

-r FILE --reject-file=FILE Output rejects to FILE.

-D NAME --ifdef=NAME Make merged if-then-else output using NAME.

-m --merge Merge using conflict markers instead of creating reject files.

-E --remove-empty-files Remove output files that are empty after patching.

-Z --set-utc Set times of patched files, assuming diff uses UTC (GMT).

-T --set-time Likewise, assuming local time.

--quoting-style=WORD output file names using quoting style WORD.

Valid WORDs are: literal, shell, shell-always, c, escape.

Default is taken from QUOTING_STYLE env variable, or 'shell' if unset.

Backup and version control options:

-b --backup Back up the original contents of each file.

--backup-if-mismatch Back up if the patch does not match exactly.

--no-backup-if-mismatch Back up mismatches only if otherwise requested.

-V STYLE --version-control=STYLE Use STYLE version control.

STYLE is either 'simple', 'numbered', or 'existing'.

-B PREFIX --prefix=PREFIX Prepend PREFIX to backup file names.

-Y PREFIX --basename-prefix=PREFIX Prepend PREFIX to backup file basenames.

-z SUFFIX --suffix=SUFFIX Append SUFFIX to backup file names.

-g NUM --get=NUM Get files from RCS etc. if positive; ask if negative.

Miscellaneous options:

-t --batch Ask no questions; skip bad-Prereq patches; assume reversed.

-f --force Like -t, but ignore bad-Prereq patches, and assume unreversed.

-s --quiet --silent Work silently unless an error occurs.

--verbose Output extra information about the work being done.

--dry-run Do not actually change any files; just print what would happen.

--posix Conform to the POSIX standard.

-d DIR --directory=DIR Change the working directory to DIR first.

--reject-format=FORMAT Create 'context' or 'unified' rejects.

--binary Read and write data in binary mode.

--read-only=BEHAVIOR How to handle read-only input files: 'ignore' that they

are read-only, 'warn' (default), or 'fail'.

-v --version Output version info.

--help Output this help.

Report bugs to .

CLi@PC-CLI-1 ~/develop/buildroot/diff_patch

$

【总结】

可以看出:-R:reverse,表示撤回打补丁,还原内容和之前的猜测,也是一致的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值