Simple Sand Samples |
説明のないとってもシンプルなサンプルプログラム集
COBOL | awk | C言語 | D言語 | GO言語 | Lua | Vim |
bash | Perl | Gauche | Clojure | CLISP | EmacsLisp | VimScript |
tcsh | Ruby | Groovy | Java | C# | VBScript | JavaScript |
Io言語 | Python | Erlang | Scala | VB.NET | Excel/VBA | PHP |
Tcl | Haskell | OCaml | PowerShell | Windows | Unix/Linux |
Linuxコマンド > diff ファイル比較
|
|
~$ paste file1 file2
apple apple
banana BANANA
cat cat
dog dog
egg egg
fun fan
good good
ice ice
jam jam
hat
~$
2c2
< banana
---
> BANANA
6c6
< fun
---
> fan
10d9
< hat
~$
6c6
< fun
---
> fan
10d9
< hat
~$
d2 1
a2 1
BANANA
d6 1
a6 1
fan
d10 1
~$
apple apple
banana | BANANA
cat cat
dog dog
egg egg
fun | fan
good good
ice ice
jam jam
hat <
~$
banana | BANANA
fun | fan
hat <
~$
--- file1 2015-04-10 19:16:47.000000000 +0900
+++ file2 2015-04-10 19:17:56.000000000 +0900
@@ -1,10 +1,9 @@
apple
-banana
+BANANA
cat
dog
egg
-fun
+fan
good
ice
jam
-hat
~$
*** file1 2015-04-10 19:16:47.000000000 +0900
--- file2 2015-04-10 19:17:56.000000000 +0900
***************
*** 1,10 ****
apple
! banana
cat
dog
egg
! fun
good
ice
jam
- hat
--- 1,9 ----
apple
! BANANA
cat
dog
egg
! fan
good
ice
jam
~$
--- file1 2015-04-10 19:16:47.000000000 +0900
+++ file2 2015-04-10 19:17:56.000000000 +0900
@@ -1,3 +1,3 @@
apple
-banana
+BANANA
cat
@@ -5,3 +5,3 @@
egg
-fun
+fan
good
@@ -9,2 +9 @@
jam
-hat
~$
*** file1 2015-04-10 19:16:47.000000000 +0900
--- file2 2015-04-10 19:17:56.000000000 +0900
***************
*** 1,3 ****
apple
! banana
cat
--- 1,3 ----
apple
! BANANA
cat
***************
*** 5,7 ****
egg
! fun
good
--- 5,7 ----
egg
! fan
good
***************
*** 9,10 ****
jam
- hat
--- 9 ----
~$
apple apple
banana BANANA
cat cat
dog dog
egg egg
fun fan
good good
ice ice
jam jam
hat
~$
ファイルを比較する
~$ diff file1 file22c2
< banana
---
> BANANA
6c6
< fun
---
> fan
10d9
< hat
~$
大文字小文字は同一視してファイル比較
~$ diff -i file1 file26c6
< fun
---
> fan
10d9
< hat
~$
比較結果をRCS形式で表示
~$ diff -n file1 file2d2 1
a2 1
BANANA
d6 1
a6 1
fan
d10 1
~$
比較結果を左右に並べて表示(Width=22文字)
~$ diff -y -W22 file1 file2apple apple
banana | BANANA
cat cat
dog dog
egg egg
fun | fan
good good
ice ice
jam jam
hat <
~$
比較結果を左右に並べて差分のみ表示
~$ diff -y -W22 --suppress-common-line file1 file2banana | BANANA
fun | fan
hat <
~$
比較結果をUNIFIED形式で表示
~$ diff -u file1 file2--- file1 2015-04-10 19:16:47.000000000 +0900
+++ file2 2015-04-10 19:17:56.000000000 +0900
@@ -1,10 +1,9 @@
apple
-banana
+BANANA
cat
dog
egg
-fun
+fan
good
ice
jam
-hat
~$
比較結果をCOPIED形式で表示
~$ diff -c file1 file2*** file1 2015-04-10 19:16:47.000000000 +0900
--- file2 2015-04-10 19:17:56.000000000 +0900
***************
*** 1,10 ****
apple
! banana
cat
dog
egg
! fun
good
ice
jam
- hat
--- 1,9 ----
apple
! BANANA
cat
dog
egg
! fan
good
ice
jam
~$
UNIFIED形式で、差分行の前後のみ表示(前後1行表示)
~$ diff -U1 file1 file2--- file1 2015-04-10 19:16:47.000000000 +0900
+++ file2 2015-04-10 19:17:56.000000000 +0900
@@ -1,3 +1,3 @@
apple
-banana
+BANANA
cat
@@ -5,3 +5,3 @@
egg
-fun
+fan
good
@@ -9,2 +9 @@
jam
-hat
~$
COPIED形式で、差分行の前後のみ表示(前後1行表示)
~$ diff -C1 file1 file2*** file1 2015-04-10 19:16:47.000000000 +0900
--- file2 2015-04-10 19:17:56.000000000 +0900
***************
*** 1,3 ****
apple
! banana
cat
--- 1,3 ----
apple
! BANANA
cat
***************
*** 5,7 ****
egg
! fun
good
--- 5,7 ----
egg
! fan
good
***************
*** 9,10 ****
jam
- hat
--- 9 ----
~$