Skip to content

Instantly share code, notes, and snippets.

@mkouhei
Created February 9, 2015 03:04
Show Gist options
  • Save mkouhei/08d22e636bcb73950fcf to your computer and use it in GitHub Desktop.
Save mkouhei/08d22e636bcb73950fcf to your computer and use it in GitHub Desktop.
#!/bin/sh -e
unset LANG
key=""
ctime="+0"
test -z $1 && ctime="-365"
test -z $2 && key="total"
check_python() {
printf "%-12s:" "Python"
find -path "*/upstream" -prune \
-o -path "*/*debpkg" -prune \
-o -path "*/.tox" -prune \
-o -path "*/*.egg" -prune \
-o -path "*/venv" -prune \
-o -path "*/_build" -prune \
-o -name "*.py" \
-a -ctime $ctime \
-a -type f | \
grep -v -E "/migrations/|.egg" | xargs wc -l 2>/dev/null | grep "$key"
}
check_shell() {
printf "%-12s:" "Shell script"
find -path "*/upstream" -prune \
-o -path "*/*debpkg" -prune \
-o -name "*.sh" \
-a -ctime $ctime \
-a -type f | \
grep -v /migrations/ | xargs wc -l 2>/dev/null | grep "$key"
}
check_golang() {
printf "%-12s:" "Go"
find -path "*/upstream" -prune \
-o -path "*/*debpkg" -prune \
-o -path "*/_build" -prune \
-o -path "*/gocode" -prune \
-o -path "*/.git" -prune \
-o -path "*/go-tour-72382f964b32" -prune \
-o -name "*.go" \
-a -ctime $ctime \
-a -type f | xargs wc -l 2>/dev/null | grep "$key"
}
check_ansible() {
printf "%-12s:" "Ansible"
find -path "*/upstream" -prune \
-o -path "*/*debpkg" -prune \
-o -name "*.yml" \
-a -ctime $ctime \
-a -type f | xargs wc -l 2>/dev/null | grep "$key"
}
check_code() {
cd $1
echo "[$1]"
check_golang
check_python
check_shell
check_ansible
}
check_code ~/devel
check_code ~/work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment