wisecrack
wisecrack

Reputation: 335

How to grep for only one `+`at the beginning of a line?

I am trying to grep for only one +at the beginning of a line as follows,I get the lines which has more than one + like +++ ,the grep should only show lines with one + ,any guidance on how to fix it?

$ git diff-tree --word-diff=porcelain -p -r 833d9653863f84fce6d04f62896c781d8b88794a|grep '^+'
+++ b/comvendorfeatureInterface.cpp
+func(function1, function2());variable

CURRENT OUTPUT:-

+++ b/comvendorfeatureInterface.cpp
+func(function1, function2());variable

EXPECTED OUTPUT:-

+func(function1, function2());variable

Upvotes: 1

Views: 40

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207435

Maybe search for + followed by not a +:

grep '^+[^+]' file

Upvotes: 2

Related Questions