26、linux shell常用的几个函数,diff

简介: 1、diff 1)Name diff - find differences between two files Synopsis diff [options] from-file to-file Description In the simplest ca...

1、diff

1)Name

diff - find differences between two files

Synopsis

diff [options] from-file to-file

Description

In the simplest case, diff compares the contents of the two files from-file and to-file.

2)option

    a single letter preceded by -, and the other of which is a long name preceded by --. Multiple single letter options (unless they take an argument) can be combined into a single command line word: -ac is equivalent to -a -c. Long named options can be abbreviated to any unique prefix of their name. Brackets ([ and ]) indicate that an option takes an optional argument.

(1) -a:将所有文件当作文本文件来进行比较by line

(2) -b 忽略空格

   -B 忽略空行

  -H 利用试探法加速对大文件的搜索

   -i 忽略大小写

   -r 比较目录中的文件

   -N 将不存在的文件当作空文件处理

   -u 使用 unified 格式。-U《列数》或–unified=《列数》,以合并的方式来显示文件内容的不同。

   -y Use the side by side output format.

      --left-column 使用-y参数时,若两个文件某一行内容相同,则仅在左侧栏位显示该行内容。

      --suppress-common-lines 使用-y参数时,仅显示不同之处。

   -W columns Use an output width of columns in side by side format.使用y参数时使用。

   -T 在每行前面加上tab字符以便对齐

   -p 若比较的文件为C语言的程序码文件时,显示差异所在的函数名称。

   -c 显示全部内文,并标出不同之处。

   -q 仅显示是否相同

3)示例

(1) diff test test2

    以小于号开始的就是第一个文件中存存的,以大于号开始的就是在第二个文件中出现的。字母adc分别表示附加、删除和修改操作。diff能区别块和字符设备文件以及FIFO(管道文件),不会把它们与普通文件进行比较。

(2)  diff -i -y -W 80 test test1

参考

1http://www.flatws.cn/article/program/shell/2011-02-23/14053.html

2http://linux.die.net/man/1/diff

3】 对参数进行了很好解释

http://www.phpzixue.cn/detail976.shtml

http://www.wycode.com/linux/shell/2011/0809/1404.html

4http://www.isstudy.com/linux/387.html

目录
相关文章
|
17天前
|
Web App开发 Java Linux
Linux之Shell基本命令篇
Linux之Shell基本命令篇
Linux之Shell基本命令篇
|
23天前
|
Linux
关于Linux目录访问函数总结
关于Linux目录访问函数总结
13 1
|
30天前
|
算法 Linux C++
【Linux系统编程】深入解析Linux中read函数的错误场景
【Linux系统编程】深入解析Linux中read函数的错误场景
205 0
|
30天前
|
存储 算法 Linux
【Linux系统编程】深入理解Linux目录扫描函数:scandir目录函数(按条件扫描目录
【Linux系统编程】深入理解Linux目录扫描函数:scandir目录函数(按条件扫描目录
39 0
|
2天前
|
算法 Linux Shell
【linux进程(二)】如何创建子进程?--fork函数深度剖析
【linux进程(二)】如何创建子进程?--fork函数深度剖析
|
15天前
|
存储 Shell Linux
【攻防世界】unseping (反序列化与Linux bash shell)
【攻防世界】unseping (反序列化与Linux bash shell)
|
16天前
|
Shell 应用服务中间件 nginx
shell学习(七) 【shell 函数】
shell学习(七) 【shell 函数】
8 1
|
17天前
|
Linux 开发者
Linux文件编程(open read write close函数)
通过这些函数,开发者可以在Linux环境下进行文件的读取、写入和管理。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
85 4
|
18天前
|
Shell Linux
【Linux】12. 模拟实现shell
【Linux】12. 模拟实现shell
27 2
|
24天前
|
Shell Linux
Linux的shell入门教程shell脚本入门教程
Linux的shell入门教程shell脚本入门教程
15 0