比较文件Linux基本命令:cmp
(2009-11-04 10:42:55)
用途:
比较两个文件的不同。
用法:
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]
选项说明:
-b --print-bytes 输出不同的字节
-i SKIP --ignore-initial=SKIP 跳过开始的SKIP大小开始比较
-i SKIP1:SKIP2 --ignore-initial=SKIP1:SKIP2
跳过FILE1开始的SKIP1以及FILE2的SKIP2字节开始比较。
-l --verbose 显示每一个不同点的字节号(10进制)和不同的字节内容(8进制).
-n LIMIT --bytes=LIMIT 最多比较LIMIT个字节
-s --quiet --silent 对文件之间的差别不现实任何信息,仅仅返回代码。相同0,不同1,不可访问2
-v --version 输出版本号
--help 输出帮助文件
SKIP1 and SKIP2 are the number of bytes to skip in each file.
SKIP1和SKIP2都是要跳过的字节数。同时SKIP可以使用一下单位。
SKIP values may be followed by the following multiplicative
suffixes:
kB 1000, K 1024, MB 1,000,000, M 1,048,576,
GB 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z,
Y.
If a FILE is `-' or missing, read standard input.
如果FILE是`-`或者没有,表示是标准输入。
例子:
[root@localhost Desktop]# cmp money infile 1K
cmp: EOF on money
[root@localhost Desktop]# cmp money infile 1K 1K
[root@localhost Desktop]# cmp money infile
money infile differ: byte 1, line 1
[root@localhost Desktop]# cmp -b money infile
money infile differ: byte 1, line 1 is 61 1 40
[root@localhost Desktop]# cmp -b money infile 2 3
money infile differ: byte 1, line 1 is 60 0 147 g
[root@localhost Desktop]# cmp -l money infile money 3 8
cmp: invalid --ignore-initial value `money'
cmp: Try `cmp --help' for more information.
[root@localhost Desktop]# cmp -l money infile 3 8
1 12 156
2 62 147
3 60 12
4 60 123
5 12 150
6 61 145
7 60 154
8 60 154
9 60 171
10 12 40
11 63 110
12 60 157
13 60 162
14 12 167
15 61 151
16 61 164
17 60 172
18 60 12
19 60 124
20 12 171
21 64 154
22 60 145
23 60 162
24 12 40
cmp: EOF on money
[root@localhost Desktop]# cmp -s money infile 3 8
//这个没有输出,有些不太明白为什么???不知道???1
分享:
喜欢
0
赠金笔
加载中,请稍候......
评论加载中,请稍候...
发评论
登录名: 密码: 找回密码 注册记住登录状态
昵 称:
评论并转载此博文
发评论
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。
后一篇 >自闭