官术网_书友最值得收藏!

The diff command

The diff command is used to find differences between two files. Let's see a few examples to find out its usage. The content of file1 is as follows:

I go for shopping on Saturday 
I rest completely on Sunday 
I use Facebook & Twitter for social networking 

The content of file2 is as follows:

Today is Monday. 
I go for shopping on Saturday 
I rest completely on Sunday 
I use Facebook & Twitter for social networking 

Type the diff command:

    $ diff file1 file2

The output will be this:

    0a1
    > Today is Monday

In the output, 0a1 tells us that line number 1 is added in file2. Let's see another example with line deletion. The content of file1 is as follows:

Today is Monday 
I go for shopping on Saturday 
I rest completely on Sunday 
I use Facebook & Twitter for social networking 

The content of file2 is as follows:

Today is Monday 
I go for shopping on Saturday 
I rest completely on Sunday 

Type the diff command:

    $ diff file1 file2

The output is as follows:

    4d3
    < I use Facebook & Tweeter for social networking.

In the output, 4d3 tells us that line number 4 is deleted in file2. Similarly, the c command will show us changes to a file as well.

主站蜘蛛池模板: 安康市| 嘉黎县| 深圳市| 津南区| 镇沅| 安徽省| 新兴县| 商河县| 大丰市| 尖扎县| 灵台县| 科技| 巴里| 阜南县| 边坝县| 监利县| 叶城县| 获嘉县| 中西区| 汉沽区| 宁津县| 图木舒克市| 和平县| 且末县| 正蓝旗| 洛阳市| 金沙县| 青浦区| 景泰县| 龙山县| 府谷县| 黄骅市| 常熟市| 吉首市| 云龙县| 岐山县| 库车县| 九龙城区| 四子王旗| 盖州市| 汪清县|