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

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.

主站蜘蛛池模板: 六安市| 塔河县| 醴陵市| 泾川县| 永安市| 栖霞市| 民县| 绥德县| 苏尼特右旗| 洛扎县| 都兰县| 长子县| 海阳市| 周口市| 襄城县| 巧家县| 剑阁县| 大冶市| 博白县| 武鸣县| 宁陕县| 梁山县| 互助| 佛教| 昌江| 隆安县| 平阳县| 清徐县| 台东县| 江安县| 沈丘县| 新源县| 芜湖县| 裕民县| 上蔡县| 西乌| 香格里拉县| 巨野县| 林口县| 五峰| 滕州市|