User Tools

Site Tools


утилиты_diff_и_patch

This is an old revision of the document!


Утилиты diff и patch

Сравнение каталогов

$ diff каталог1 каталог2

Сравнение двоичных файлов

$ diff /bin/ls /usr/bin/lsvfs 
Binary files /bin/ls and /usr/bin/lsvfs differ

Сравнение текстовых файлов

$ cat hello.c
#include <stdio.h>
main () {
        printf("Hello World\n");
}

$ cp hello.c hello.c.old
$ ee hello.c
…
$ cat hello.c
#include <stdio.h>
main () {
        printf("Hello World Again\n");
}

$ diff hello.c.old hello.c 
3c3
<       printf("Hello World\n");
---
>       printf("Hello World Again\n");

$ diff hello.c.old hello.c > patch.txt

Копируем patch.txt на машину со старым hello.c

$ patch hello.c patch.txt
Hmm...  Looks like a normal diff to me...
Patching file wares.txt using Plan A...
Hunk #1 succeeded at 3.
done

$ cat hello.c
#include <stdio.h>
main () {
        printf("Hello World Again\n");
}
утилиты_diff_и_patch.1235987677.txt.gz · Last modified: 2013/05/22 13:50 (external edit)