kerner1000
kerner1000

Reputation: 3558

Git status summary by file extension

Is there a possibility to change the output of git status, so that is shows only one line per file extension? e.g,

M *.java -> 12
D *.html -> 2
M *.md -> 1

I am on Unix, so some grep magic would do as well.

Upvotes: 4

Views: 2824

Answers (2)

spbroma
spbroma

Reputation: 31

The better is to add sort, because files can be in different folders

git status -s | awk '{print $2}'     \
          | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/'  \
          | sort   \
          | uniq -c

Upvotes: 0

cn0047
cn0047

Reputation: 17071

Try this:

git status -s | awk '{print $2}' \
    | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' \
    | uniq -c

Where:
awk '{print $2}' - match updated files
sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' - extract file extension
uniq -c - calcalate count

Upvotes: 2

Related Questions