在将这两行与diff进行比较时,这些数字告诉我什么?

时间:2014-03-13 22:28:34

标签: diff

也许我只是看不到树木。我想了解如何解释突出显示的数字。

这取自手册页。

diff -u lao tzu

差异如下:

--- lao Sat Jan 26 23:30:39 1991
+++ tzu Sat Jan 26 23:30:50 1991

@@ -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!

帮助文件说:

@@ from-file-range to-file-range @@
 line-from-either-file
 line-from-either-file...

如何解释@@ -1,7 +1,6 @@@@ -9,3 +8,6 @@?可能这很明显,但我不明白这个想法。谢谢!

1 个答案:

答案 0 :(得分:2)

  

@@-1,7 +1,6@@

它告诉您以下更改块应用于哪些文件行。

  • -1表示以下更改块从原始文件的第1行开始。
  • 7表示更改块应用于原始文件的7行。
  • +1表示更改块从新文件的第1行开始。
  • 6表示更改块应用于新文件的6行。

在随后的更改块中,前面带有-的行是删除行,前面带有+的行是附加行,前面带有(空格)的行是不变。

参考:diff - Unified format