Skip to content

Instantly share code, notes, and snippets.

@hytopoulos
Created December 13, 2022 06:48
Show Gist options
  • Save hytopoulos/948a2e8b57c53d3ca566b3520ae1f07c to your computer and use it in GitHub Desktop.
Save hytopoulos/948a2e8b57c53d3ca566b3520ae1f07c to your computer and use it in GitHub Desktop.
Count lines of code for a specific language using git blame
#!/bin/bash
c_files=$(find . -name "*.c")
loc=0
# Loop through each C file
for file in $c_files; do
loc=$((loc + $(git blame $file | grep $1 | wc -l)))
done
echo "Total LOC of C authored by $1: $loc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment