2012년 11월 28일 수요일

diff: tips of Linux/Unix files/dirs comparing tool

usage: diff [options] file1 file2 [dir1 dir2]
       colordiff [options] file1 file2 [dir1 dir2]

Useful options

-s, --report-identical-files
    report when two files are the same (there is no output when same as default)
    파일이 완전히 같을 경우, 같다고 출력해준다. (기본적으로 아무 출력도 안 한다.)

-b, --ignore-space-change
    ignore changes in the amount of white space
    빈 칸 부분이 다른 경우 무시한다.

-r, --recursive
    recursively compare any subdirectories found
    하위 디렉토리도 비교한다.

Analysis of a result

$diff oldfile newfile
5c5
< this line 5 of oldfile is different from
> this line 5 of newfile.
7d6
< this line 7 of oldfile only appears in oldfile, does not appear in newfile.
21a22
> this line 22 of newfile is a missing line at line 21 of oldfile


#1[cda]#2
#1 is a line number of oldfile
#2 is a line number of newfile
'c' means 'change' to sync
'd' means 'delete' the line #1 of oldfile to sync
'a' means 'add' the line #2 of newfile after the line #1 of oldfile to sync

< means a line of oldfile
> means a line of newfile

colordiff

colordiff is a wrapper for diff, it shows the same output as diff but with colored syntax highlighting, so highly recommended.

댓글 없음:

댓글 쓰기

Xubuntu: Installing a Printer (Canon G3060 PIXMA)

$ sudo apt install system-config-printer Download the proper driver for linux from Canon website. Turn on the printer and set up its WiFi. C...