Git diff parse in shell script

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
~

I need only -2 and +3
How to do that using grep or shell script?

  • Bash prefix command name for subcommands
  • git diff just the first file (of all unstaged changes)
  • Git Bash (Windows) not using PATH
  • Git: Getting total numbers of uncomitted lines in a repo
  • How could I parse an output command with shell scripting?
  • Non-Terminating Process Git Bash (C#)
  • tried to push to GitHub, now getting 'fatal: bad default revision'
  • .gitignore ignore all files then recursively allow *.foo
  • How do you roll back (reset) a Git repository to a particular commit?
  • Recover overwritten file with eclipse git
  • git see entire merge diff
  • Integrating public git repository into private project (without submodules or subtree merge)
  • One Solution collect form web for “Git diff parse in shell script”

    Pipe the output into

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

    So:

    diff --git a/lids b/lids | grep '^[+-][0-9]'
    
    Git Baby is a git and github fan, let's start git clone.