Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

diff | ファイルの内容を比較

概要

diffでファイルの内容を比較

構文

diff <フォルダ名>/ <フォルダ名>/
diff <ファイル名> <ファイル名>

条件

下記の構成を前提とする。

current directory
┣target1
┃ ┃test1.txt
┃ ┗test2.txt
┗target2
    ┃test1.txt
    ┗test2.txt

ファイルの中身(target2\test1.txt以外は全て同じ内容)

hoge
foo
bar

ファイルの中身(target2\test1.txt)

hogo
foo
bar
piyo

コマンド

$diff target1/ target2/
diff target1//test1.txt target2//test1.txt
1c1
< hoge
---
> hogo
3a4
> piyo