Skip to content

Instantly share code, notes, and snippets.

@posva
Created September 2, 2014 14:09
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 posva/08ff133f5fbaf739c796 to your computer and use it in GitHub Desktop.
Save posva/08ff133f5fbaf739c796 to your computer and use it in GitHub Desktop.
Generates a dirtree (LaTex) view with line count
#! /bin/bash
L=$(echo index_a6_se_ast.html index_a6_se_tst.html js_a6_se_ast/*.js js_a6_se_tst/*.js js/lib/qtBinding.js js/lib/nuntius.js js_a6_se_tst/css/main.css json/README.md json/genjs.sh json/genjson.py json/a6JSONValidator.js)
N=$(cat $L | wc -l)
echo "Total $N"
old=''
for i in $L; do
T=$(wc -l $i)
lines=$(echo "$T" | cut -d " " -f1)
file=$(echo "$T" | cut -d " " -f2)
level=$(echo "$file" | sed 's/[^/]//g' | wc -c)
dir=$(dirname "$file")
if [ ! "$dir" = "$old" ]; then
lv=$(echo "$dir" | sed 's/[^/]//g' | wc -c)
if [ "$dir" = "." ];then
echo ".$lv Total \\DTcomment{$N}."
else
echo ".$lv $(basename "$dir" | sed 's/_/\\_/g')."
fi
old="$dir"
fi
echo ".$level $(basename "$file" | sed 's/_/\\_/g') \\DTcomment{$lines}."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment