Tomáš Šíma
Tomáš Šíma

Reputation: 864

git diff, getting just the changed characters

I want to get list of all characters, that were used to change files in directory.

The closest I got to this problem was using:

git diff --color-words="[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+"
--no-index ./original_directory/ ./changed_directory/

By using this command, I get lines with highlighted characters, which were changed. Is there any way to sed/grep/awk the output, so that output will be just the colored characters?

Upvotes: 0

Views: 1139

Answers (1)

Zombo
Zombo

Reputation: 1

git diff --color | awk '/^\33\[3[12]m/'
  1. Use --color so that colors are passed to Awk

  2. Green lines will begin with the escape sequence \33[32m

  3. Red lines will begin with the escape sequence \33[31m

Example

Upvotes: 2

Related Questions