Home > Net >  How can I get line numbers where changes where introduced?
How can I get line numbers where changes where introduced?

Time:07-28

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,]*'

CodePudding user response:

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 "^@@"
  • Related