Skip to content

Instantly share code, notes, and snippets.

@yukihirai0505
Created May 7, 2019 08:59
Show Gist options
  • Save yukihirai0505/5975d65de1bfbf3c4495f4e45bca913f to your computer and use it in GitHub Desktop.
Save yukihirai0505/5975d65de1bfbf3c4495f4e45bca913f to your computer and use it in GitHub Desktop.
Counting lines of code (specific directories and files)
#!/usr/bin/env bash
# cloc ver
MODULES=(hoge fuga piyo)
for MODULE in "${MODULES[@]}"
do
TARGET_DIC=./${MODULE}
cloc ${TARGET_DIC} --read-lang-def=$HOME/cloc/language-defs.txt --include-lang=Java,PHP | awk -v env_var="${MODULE}" 'FNR == 12 {print "|" env_var "|" $3+$4+$5 "|" $4+$5 "|"}'
done
#!/usr/bin/env bash
# pure script ver
MODULES=(hoge fuga piyo)
for MODULE in "${MODULES[@]}"
do
echo $MODULE
TARGET_DIC=./${MODULE}
EXCEPT_DIC=${TARGET_DIC}/build
find ${TARGET_DIC} -path ${EXCEPT_DIC} -prune -o -name '*.gs' -o -name '*.gsx' | xargs wc -l 2>/dev/null | awk 'END{print $1}'
find ${TARGET_DIC} -path ${EXCEPT_DIC} -prune -o -name '*.gs' -o -name '*.gsx' | xargs sed '/^[[:space:]]*$/d' | wc -l | awk '{print $1"(no blank)"}'
echo "==="
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment