1

git diff

diff --git a/lids b/lids
index 009d7e8..46447a8 100644
--- a/lids
+++ b/lids
@@ -1,12 +1,12 @@
-FP CA1 CAPS Mapping.pdf
 mtool1428_100squaretool.html
+mtool1428_100squaretool.py
 Lesson Guide 100square 23LessonIdeas.pdf
 Worksheet 100square 0to99.pdf
 Worksheet 100square 1to100.pdf
 Worksheet 100square Blank.pdf
-Worksheet 100square Challenge 1.pdf
-Worksheet 100square Challenge 2.pdf
+Worksheet 100square Challenge 11.pdf
 Worksheet 100square Challenge 3.pdf
+Worksheet 100square Challenge 2.pdf
 Worksheet 100square Challenge 4.pdf
 Worksheet 100square Challenge 5.pdf
 Worksheet 100square Challenge 6.pdf

How to grep deleted strings starting with a single - sign and string starting with single + sign

1
  • 1
    Don't, don't attempt to filter lines from the diff in this manner. (Did you notice the lines containing the filenames that start with --- and +++?) Commented Feb 13, 2014 at 14:17

2 Answers 2

2

How to grep deleted strings starting with a single - sign and string starting with single + sign

You can use this egrep:

grep '^ *[-+][a-zA-Z0-9]'

OR this:

grep '^ *[-+][[:alnum:]]'

OR this:

grep '^ *[-+][^-+]' 
Sign up to request clarification or add additional context in comments.

5 Comments

yeah I missed it... Thanks anubhava
You could do [^+-] as well, instead of [a-zA-Z0-9] to say "only a single + or - sign"
@rabin: May I know what was wrong with my answer here that you had to remove acceptance mark?
I want to give acceptance to both of the answers..... so while giving acceptance to another answer, yours was unchecked, which i noticed just now.....i have accepted it again...thanks for pointing (lesson learnt.. only one answer can be accepted :)
Yes that's true only one is accepted (usually first and correct one). You can always upvote the other answer.
1

The following command shows lines with '-' or '+' from the beginning of each line that are not followed by '-' or '+'

git diff <file> | grep ^[-+][^-+]

1 Comment

Working nicely...Thanks Luis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.