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,新创建的目录权限是 ...
随机推荐
- AirtestIDE详解(跨平台的UI自动化编辑器)
Airtest 是网易出品的一款基于图像识别和poco控件识别的一款UI自动化测试工具. AirtestIDE 是一个跨平台.多端(Windows.web.android.ios.游戏)的UI自动化测 ...
- easyui -tree的详细讲解
代码的具体实现 @{ ViewBag.Title = "人员查找"; ViewBag.LeftWidth = "200px"; ViewBag ...
- Spring Web MVC核心架构
可以查看DispatherServlet中的源代码,就是doDispatch()方法!
- java中的结构--switch选择结构
if-switch 选择结构 switch结构可以更好的解决等值判断问题switch 选择结构的语法:switch (表达式){ case 常量 1: //代码块1: break; case 常量 2 ...
- nodejs全局安装路径的位置
一般nodejs安装在默认的C盘,如果不知道安装在哪里,可以打开控制面板-系统和安全-系统-高级配置中找到 所谓全局安装: 是指安装在node中node_module的根目录里,可以在电脑的任何位置调 ...
- html5——伸缩布局
基本概念 1.主轴:Flex容器的主轴主要用来配置Flex项目,默认是水平方向 2.侧轴:与主轴垂直的轴称作侧轴,默认是垂直方向的 3.方向:默认主轴从左向右,侧轴默认从上到下 4.主轴和侧轴并不是固 ...
- Mysql 之show status数据详解
状态名 作用域 详细解释 Aborted_clients Global 由于客户端没有正确关闭连接导致客户端终止而中断的连接数 Aborted_connects Global 试图连接到MySQL服务 ...
- jquery spa
1.hashchange监听 2.根据url加载不同页面 $.ajax({ url:"/xx/xx.html" type:"get", dataType:&qu ...
- hstack()与vstack()函数
ref: https://blog.csdn.net/csdn15698845876/article/details/73380803 1. hstack()函数 a,b只有一个维度:对第一个维度拼接 ...
- UVALive 3026(KMP算法)
UVALive 3026 KMP中next[]数组的应用: 题意:给出一个字符串,问该字符串每个前缀首字母的位置和该前缀的周期. 思路:裸KMP直接上就是了: 设该字符串为str,str字符串 ...