まだ目grepで消耗してるの?テキストファイルの比較で?gitの差分みたいな Linuxのdiffコマンド使ってる?


gitなどのコアにも使われていると勝手に@yumainauraが想像してるコマンド。

こんなテキストファイルを二個作る

text1

A
B
C

test2

B
C
D

作成例

touch ~/tmp/text1; echo A > ~/tmp/text1; echo B > ~/tmp/text1; echo C > ~/tmp/text1;
touch ~/tmp/text2; echo B > ~/tmp/text2; echo C > ~/tmp/text2; echo D > ~/tmp/text2;

Diff!

$ diff /tmp/text1 /tmp/text2
1c1
< C
---
> D

いつも見慣れたプラスマーク、マイナスマークで出すにはこれ!

$ diff -u /tmp/text1 /tmp/text2
--- /tmp/text1  2018-12-27 19:13:19.000000000 +0900
+++ /tmp/text2  2018-12-27 19:13:34.000000000 +0900
@@ -1 +1 @@
-C
+D

Cが少なく
Dが多いことが分かる

linux yumainaura - Google Search