linux 文件夹比较工具,Linux下的文件比较工具diff和sdiff

文件比较是非常需要的功能,比如判断两个程序的源码文件的不同版本的差异。BeyondCompare尽管功能强大,但要注册;Meld也是不错的工具,也可以跨平台。有没有轻量级的工具呢?在Linux下有diff和sdiff,Windows下有WinDiff,基本的文件差异比较能达到,值得考虑。

How do I Compare two files under Linux or UNIX?

You need to use diff command to display line-by-line difference between two files. The general syntax of diff command as follows:

diff FILE1 FILE2

Where,

FILE1 FILE2: Diff command will examine both file1 and file2 and tells you what changes need to be made for file1 and file2 to match. Please note that diff command point to which lines need be: Added (a)

Deleted (d)

Changed (c)

Further lines in file1 identified with a less than () symbol and lines in file2 with a grater than (>) symbol.

Examples

diff file1.txt file2.txt

Output: 8c8,9 URL: www.nixcraft.in > Email: support@nixcraft.in

The contents of both files:

$ cat file1.txt

Output: Welcome to nixCraft! If undeliverd return to nixCraft #404, DC bay area, 2nd phase, Pune. Ph: 555-11112223 URL: www.nixcraft.com

$ cat file2.txt

Output: Welcome to nixCraft! If undeliverd return to nixCraft #404, DC bay area, 2nd phase, Pune. Ph: 555-11112223 URL: www.nixcraft.in Email: support@nixcraft.in

Side-by-side merge of file differences

You can get a clear-cut visual difference between two text files using the command sdiff:

$ sdiff file1.txt file2.txt

Output: Welcome to nixCraft! Welcome to nixCraft! If undeliverd return to nixCraft If undeliverd return to nixCraft #404, DC bay area, 2nd phase, #404, DC bay area, 2nd phase, Pune. Pune. Ph: 555-11112223 Ph: 555-11112223 URL: www.nixcraft.com | URL: www.nixcraft.in > Email: support@nixcraft.in

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值