Skip to content

Diff

컴퓨터에서 diff는 두 개의 파일 간 차이에 대한 정보를 출력하는 파일 비교 유틸리티이다. 일반적으로 하나의 파일 버전과 동일한 파일의 다른 버전 간의 변경 사항을 보여주는 데 쓰인다. diff는 문서 파일의 줄 사이 변경 사항을 보여준다. 이 명령어로 만든 파일은 유닉스 계열 프로그램인 patch 명령어를 이용하여 출력물을 생성할 수 있다.

Options

-u
Unified Format 출력.
-r
하위 디렉터리도 재귀적(Recursive)으로 검색한다.
-N
새로운 파일도 Diff에 포함한다.

Example

두 개의 폴더에서 변경점을 Unified Format으로 diff파일 출력.

$ diff -urN [원본폴더] [변경폴더] > [DIFF파일명]

두 개의 디렉터리를 비교.

$ diff -rq dir1 dir2 | sort

Binary diff

바이너리 비교: (xxd를 함께 사용한다)

$ diff -y <(xxd foo1.bin) <(xxd foo2.bin)

colordiff를 사용하는 방법도 있다:

$ colordiff -y <(xxd foo1.bin) <(xxd foo2.bin)

Text Processing Commands

텍스트 처리 명령어 목록

Text

Common

grep, sed, awk, cat, xargs, rev, tee, ack, tr, stdbuf

Diff

diff, patch

Cutting

cut, head, tail, less, more, split, watch

Sort

uniq, sort

Hash

base64, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum

Clipboard

clip (Windows), pbcopy (Mac OSX), pbpaste (Mac OSX), xclip (Debian)

E.T.C

regexp, parallel

See also

Favorite site