N天学习一个linux命令之diff
用途
按行比较文件差异,也可以比较目录
用法
diff [OPTION]... FILES
常用选项
-i --ignore-case
忽略大小写
--ignore-file-name-case
忽略文件名大小写
--no-ignore-file-name-case
文件名区分大小写
-E --ignore-tab-expansion
忽略tab字符
-b --ignore-space-change
忽略空格
-w --ignore-all-space
忽略所有空格
-B --ignore-blank-lines
忽略空白行
-I RE --ignore-matching-lines=RE
过滤匹配的行
--strip-trailing-cr
去掉行尾回车符
-a --text
所有文件内容当做文本
-c -C NUM --context[=NUM]
(Output NUM (default 3) lines of copied context.)
-u -U NUM --unified[=NUM]
(Output NUM (default 3) lines of unified context.)
--label LABEL
使用LABEL代替文件名
-p --show-c-function
显示差异行所在文件
-F RE --show-function-line=RE
(Show the most recent line matching RE.)
-q --brief
直接输出结果是否有差异
-e --ed
(Output an ed script.)
--normal
(Output a normal diff.)
-n --rcs
(Output an RCS format diff.)
-y --side-by-side
同时输出2个文件的内容,对照显示
-W NUM --width=NUM
(Output at most NUM (default 130) print columns.)
--left-column
左边输出完整内容,右边只输出差异
--suppress-common-lines
只输出差异行
-D NAME --ifdef=NAME
(Output merged file to show ‘#ifdef NAME’ diffs.)
--GTYPE-group-format=GFMT
(Similar, but format GTYPE input groups with GFMT.)
(GTYPE is LTYPE or ‘changed’.)
--line-format=LFMT
(Similar, but format all input lines with LFMT.)
--LTYPE-line-format=LFMT
(Similar, but format LTYPE input lines with LFMT.)
(LTYPE is ‘old’, ‘new’, or ‘unchanged’.)
-l --paginate
分页显示
-t --expand-tabs
输出时,tab字符换成空格
-T --initial-tab
(Make tabs line up by prepending a tab.)
-r --recursive
(Recursively compare any subdirectories found.)
-N --new-file
(Treat absent files as empty.)
--unidirectional-new-file
(Treat absent first files as empty.)
-s --report-identical-files
(Report when two files are the same.)
-x PAT --exclude=PAT
(Exclude files that match PAT.)
-X FILE --exclude-from=FILE
(Exclude files that match any pattern in FILE.)
-S FILE --starting-file=FILE
(Start with FILE when comparing directories.)
--from-file=FILE1
(Compare FILE1 to all operands. FILE1 can be a directory.)
--to-file=FILE2
(Compare all operands to FILE2. FILE2 can be a directory.)
--horizon-lines=NUM
(Keep NUM lines of the common prefix and suffix.)
-d --minimal
(Try hard to find a smaller set of changes.)
--speed-large-files
(Assume large files and many scattered small changes.)
-v --version
输出程序版本信息
--help
显示帮助信息
实践
1 比较2个文件
# 显示所有
diff -y dir1/friend.php friend.php
# 只显示差异
diff -y --suppress-common-lines dir1/friend.php friend.php
# 只显示左边完整内容,右边只显示差异内容
diff -y --left-column dir1/friend.php friend.php
擦参考资料
【1】man diff
N天学习一个linux命令之diff的更多相关文章
- N天学习一个Linux命令之帮助命令:man
前言 工作中每天都在使用常用的命令和非常用的命令,忘记了用法或者参数,都会bing一下,然后如此循环.一直没有真正的系统的深入的去了解命令的用法,我决定打破它.以前看到有人,每天学习一个linux命令 ...
- N天学习一个Linux命令之free
用途 查看系统内存(物理/虚拟/缓存/共享)使用情况 用法 free [-b | -k | -m | -g | -h] [-o] [-s delay ] [-c count ] [-a] [-t] [ ...
- N天学习一个linux命令之ping
用途 检测主机是否可到达,也就是说,目标主机是否可以联网,还可以用于检测网速.通过发送ICMP ECHO_REQUEST数据包检测. 用法 ping [options] destination 常用选 ...
- N天学习一个linux命令之kill
用途 用于终止进程 用法 kill [-s signal|-p] [--] pid... kill -l [signal] 说明 1.默认发送信号15(请求终止进程,程序可以捕获,操作系统会杀死没有对 ...
- N天学习一个linux命令之du
用途 统计文件或者目录占用硬盘空间大小 用法 du [OPTION] [FILE]du [OPTION] --files0-from=F 常用参数 -a, --all统计所有文件,不仅仅是目录 -b, ...
- N天学习一个linux命令之scp
用途 通过ssh通道,不同主机之间复制文件 用法 scp [options] [user@host:]file1 [user2@host2:]file2 常用参数 -1使用 ssh 1协议 -2使用s ...
- 每天学习一个Linux命令-目录
在工作中总会零零散散使用到各种Linux命令,从今天开始详细的学习一下linux常用命令,坚持每天一个命令,学习的主要参考资料为: 1.竹子-博客(https://www.cnblogs.com/pe ...
- 每天一个linux命令(49)--diff命令
diff 命令是 Linux 上非常重要的工具,用于比较文件的内容,特别是比较两个版本不同的文件以找到改动的地方.diff 在命令行中打印每一个行的改动.最新版本的diff还支持二进制文件,diff ...
- N天学习一个linux命令之umask
前言 umask不是linux命令,而是shell内置的指令,俗称用户权限掩码,用于对用户创建的文件和目录设置默认权限.默认的权限掩码是0022,也就是说新创建的文件权限是0644,新创建的目录权限是 ...
随机推荐
- 如何使jquery性能最佳
转自 http://www.cnblogs.com/mo-beifeng/archive/2012/02/02/2336228.html 1. 使用最新版本的jQuery jQuery的版本更新很快, ...
- 基于Spark Streaming预测股票走势的例子(二)
上一篇博客中,已经对股票预测的例子做了简单的讲解,下面对其中的几个关键的技术点再作一些总结. 1.updateStateByKey 由于在1.6版本中有一个替代函数,据说效率比较高,所以作者就顺便研究 ...
- 拼接html 的事件转义
attach += "<div style='line-height: 10px;float: left;margin-left: 10px;' id='attach_" + ...
- Android开发笔记(6)——类的设定与继承
转载请注明http://www.cnblogs.com/igoslly/p/6838991.html [类]的设定与继承 当设置相同格式的TextView时,已提出在styles.xml自定义格式统一 ...
- JS——大小写转化
<script> var str = 'JavaScript'; console.log(str.toUpperCase());//小写转大写 console.log(str.toLowe ...
- iframe监听unload事件
阻止默认事件 event.preventDefault(); 阻止事件冒泡 event.stopPropagation(); event.cancelBubble = true; //IE <a ...
- 微信小程序php后台实现
这里简单介绍用php后台实现获取openid并保存到数据库: 微信的登陆流程是这样的 首先前端发送请求到服务器: wx.login({ success: function (res) { var co ...
- [转]使用gdb调试异常
有时程序中有未捕获的异常会导致程序异常的行为甚至导致程序的直接退出. 这对服务器程序来说是不可接受的. 可以使用gdb的catch命令来帮助我们调试异常. 使用gdb捕获异常的扔出点(相当于在扔出异常 ...
- 配置本地git服务器(gitblit win7)
title: 配置本地git服务器 date: 2017年3月7日22:43:14 gitblit(不用安装) 进入gitblit-1.8.0\data下,编辑gitblit.properties和d ...
- VBA/VBScript提取Word(*.doc)文件中包含的图片(照片)
VBA/VBScript提取Word(*.doc)文件中包含的图片(照片) 要处理的人事简历表是典型的Word文档,其中一人一份doc,里面包含有个人的照片,如果要把里面的照片复制出来就比较麻烦了 ...