Diff files and folders

Diff

Standard Diff

Diff files

diff <file1> <file2>

Diff directories and their contents, showing the output of the diff for each file

diff -r <dir1> <dir2>

Diff directories and their contents, showing only the filenames of changed files

diff -qr <dir1> <dir2>

Diff directories ignoring specific files (eg. .DS_Store macOS files)

diff -x '<ignore>' -rq <dir1> <dir2>
diff -x '.DS_Store' -rq <dir1> <dir2>

Vim Diff

Diff files with side by side editable output

vim -d <file1> <file2>
vimdiff <file1> <file2>

Pipe diff output into vim for syntax highlighting

Git Diff

Compare files using the git diff tool (works outside of git repos)

VS Code Diff

Compare files using VS Code diff view

Compare

Output if specified files differ

Comm

Select or reject lines common to two files (requires sorted files as input)

Generates output in three columns (Disable columns using -<column-number...>)

  • Column 1: Lines only in file 1

  • Column 2: Lines only in file 2

  • Column 3: Lines common in both files

Show only the common lines (eg. hide column 1 and 2 -12 and keep column 3)

Show lines only in file 1

Show lines only in file 2

Sort

List lines that intersect between file 1 and file 2

List lines only in file one

Last updated