Skip to content

Instantly share code, notes, and snippets.

@leftclickben
Created October 12, 2020 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leftclickben/c0dbc549b9eefdb5eacbc56fd870a09d to your computer and use it in GitHub Desktop.
Save leftclickben/c0dbc549b9eefdb5eacbc56fd870a09d to your computer and use it in GitHub Desktop.
Source analytics
#!/bin/bash
set -u
# usage example to find all Java source files: ./sloc-by-extension java
EXTENSION="${1}"
for dir in $(ls -d */); do
pushd ${dir} >/dev/null
LIST=$(find . -name "*.${EXTENSION}" | grep -iv test)
if [ ! -z "${LIST}" ]; then
echo ${dir} | sed 's/\/\///g'
echo $(wc -l ${LIST} | tail -n 1)
fi
popd >/dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment