diff [OPTION]... FILES
beyes@debian:~/command/diff$ diff diffdir1 diffdir2
Only in diffdir1: filename
Only in diffdir2: FILENAME
beyes@debian:~/command/diff$ diff --ignore-file-name-case diffdir1 diffdir2
[beyes@localhost diff]$ cat filename.txt
hello world
[beyes@localhost diff]$ cat FILENAME.TXT
hello world
[beyes@localhost diff]$ cat filename.txt
h e llo world
[beyes@localhost diff]$ cat FILENAME.TXT
hello world
[beyes@localhost diff]$ cat filename.txt
hello world
are you ok?
[beyes@localhost diff]$ cat FILENAME.TXT
hello world
are you here?
[beyes@localhost diff]$ diff -bB filename.txt FILENAME.TXT
2,5c2
<
<
<
< are you ok?
---
> are you here?
[beyes@localhost diff]$ diff -bB -I are filename.txt FILENAME.TXT
[beyes@localhost diff]$ diff filename.txt FILENAME.txt
1,2c1,2
< are you ok?
< how are you?
---
> are you ok?
> how are you?
[beyes@localhost diff]$ diff --strip-trailing-cr filename.txt FILENAME.txt
beyes@debian:~/command/diff$ cat filename
ignore changes whose lines
another sample
for proper operation
the context output format
how are you
are you ok
what is this
what is that
welcome to gorad.net
show the most recent line
ouput ed script
ouput a normal diff
beyes@debian:~/command/diff$ diff -C 2 filename FILENAME
*** filename 2011-06-02 16:19:52.000000000 +0800
--- FILENAME 2011-06-02 16:20:04.000000000 +0800
***************
*** 5,9 ****
how are you
are you ok
! what is this
what is that
welcome to gorad.net
--- 5,9 ----
how are you
are you ok
! what is this?
what is that
welcome to gorad.net
*** filename 2011-06-02 16:19:52.000000000 +0800
--- FILENAME 2011-06-02 16:20:04.000000000 +0800
beyes@debian:~/command/diff$ diff -C 2 --label=filename --label=FILENAME filename FILENAME
*** filename
--- FILENAME
***************
*** 5,9 ****
how are you
are you ok
! what is this
what is that
welcome to gorad.net
--- 5,9 ----
how are you
are you ok
! what is this?
what is that
welcome to gorad.net
#include <stdio.h>
void diff_test(void)
{
printf ("hello diff command");
}
int main()
{
diff_test();
return 0;
}
beyes@debian:~/command/diff$ diff -p hello.c hello2.c
*** hello.c 2011-06-02 16:50:09.000000000 +0800
--- hello2.c 2011-06-02 16:50:25.000000000 +0800
***************
*** 2,8 ****
void diff_test(void)
{
! printf ("hello diff command");
}
int main()
--- 2,8 ----
void diff_test(void)
{
! printf ("hello diff command\n");
}
int main()
beyes@debian:~/command/diff$ diff -q hello.c hello2.c
Files hello.c and hello2.c differ
The Way that can be told of is not the eternal Way;
The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
The Named is the mother of all things.
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
so we may see their outcome.
The two are the same,
But after they are produced,
they have different names.
The Nameless is the origin of Heaven and Earth;
The named is the mother of all things.
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
so we may see their outcome.
The two are the same,
But after they are produced,
they have different names.
They both may be called deep and profound.
Deeper and more profound,
The door of all subtleties!
$ diff -c lao tzu
*** lao 2011-06-03 09:20:59.000000000 +0800
--- tzu 2011-06-03 09:22:00.000000000 +0800
***************
*** 1,7 ****
- The Way that can be told of is not the eternal Way;
- The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
! The Named is the mother of all things.
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
--- 1,6 ----
The Nameless is the origin of Heaven and Earth;
! The named is the mother of all things.
!
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
***************
*** 9,11 ****
--- 8,13 ----
The two are the same,
But after they are produced,
they have different names.
+ They both may be called deep and profound.
+ Deeper and more profound,
+ The door of all subtleties!
*** lao 2011-06-03 09:20:59.000000000 +0800
--- tzu 2011-06-03 09:22:00.000000000 +0800
$ diff -U 1 lao tzu
--- lao 2011-06-03 09:20:59.000000000 +0800
+++ tzu 2011-06-03 09:22:00.000000000 +0800
@@ -1,5 +1,4 @@
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
@@ -11 +10,4 @@
they have different names.
+They both may be called deep and profound.
+Deeper and more profound,
+The door of all subtleties!
$ diff -U 2 lao tzu
--- lao 2011-06-03 09:20:59.000000000 +0800
+++ tzu 2011-06-03 09:22:00.000000000 +0800
@@ -1,6 +1,5 @@
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
so we may see their subtlety,
@@ -10,2 +9,5 @@
But after they are produced,
they have different names.
+They both may be called deep and profound.
+Deeper and more profound,
+The door of all subtleties!
$ diff -u lao tzu
--- lao 2011-06-03 09:20:59.000000000 +0800
+++ tzu 2011-06-03 09:22:00.000000000 +0800
@@ -1,7 +1,6 @@
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
@@ -9,3 +8,6 @@
The two are the same,
But after they are produced,
they have different names.
+They both may be called deep and profound.
+Deeper and more profound,
+The door of all subtleties!
$ diff -U 9 lao tzu
--- lao 2011-06-03 09:20:59.000000000 +0800
+++ tzu 2011-06-03 09:22:00.000000000 +0800
@@ -1,11 +1,13 @@
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
so we may see their outcome.
The two are the same,
But after they are produced,
they have different names. #这里最多只有 7 行相同的,所以即使指定 9 也只能输出 7 行
+They both may be called deep and profound.
+Deeper and more profound,
+The door of all subtleties!
--- lao 2011-06-03 09:20:59.000000000 +0800
+++ tzu 2011-06-03 09:22:00.000000000 +0800
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |