diffコマンドでユニファイド形式で出力する方法
diffコマンドでユニファイド形式で出力するには-uオプションを指定します。
オプションの説明
-u, -U NUM, --unified[=NUM] output NUM (default 3) lines of unified context
-uオプションを指定した場合
$ diff -u test1.txt test2.txt --- test1.txt 2021-01-17 22:06:57.245502000 +0900 +++ test2.txt 2021-01-17 22:24:40.415502000 +0900 @@ -1,5 +1,4 @@ apple -banana +grape orange -lemon -peach +mango
-uオプションを指定しない場合
$ diff test1.txt test2.txt 2c2 < banana --- > grape 4,5c4 < lemon < peach --- > mango