在shell脚本中使用Git diff解析

时间:2014-02-13 13:30:56

标签: git bash shell grep ubuntu-12.04

git diff

diff --git a/lids b/lids
index 1191247..2b2f2e1 100644
--- a/lids
+++ b/lids
@@ -1,2 +1,2 @@
 1
-2
+3


git diffdiff --git a/lids b/lids
index 1191247..2b2f2e1 100644
--- a/lids
+++ b/lids
@@ -1,2 +1,2 @@
 1
~
-2
+3
~

我只需要-2和+3 如何使用grep或shell脚本?

1 个答案:

答案 0 :(得分:1)

将输出传输到

grep '^[+-][0-9]'

所以:

diff --git a/lids b/lids | grep '^[+-][0-9]'