Yola
Yola

Reputation: 19019

How can I get line numbers where changes where introduced?

I have a bunch of text files. Some changes were introduced. I need to get the list of line numbers in the original files where changes (any, editing/deletion/insertion) happened. I need it to only be line numbers, no actual changes in the text allowed to be shown.

I can put files into two folders or create git repo for with two commits for it.

I tried to use git diff but failed to find appropriate option. What are my other options?

EDIT: I used git diff -U0 | egrep "^\+{3}|^@@" | grep -Eo '^\+.*|^@@ [-0-9,]*'

Upvotes: 1

Views: 140

Answers (1)

David Grayson
David Grayson

Reputation: 87386

Try this command in your shell:

git diff -U0 | egrep "^\+{3}|^@@"

After that it takes just a little bit of parsing to get the line numbers that changed.

If you don't care about knowing what files the changes are in, try:

git diff -U0 | egrep "^@@"

Upvotes: 2

Related Questions