This simple script searches a directory for source files, and performs the following actions:
#!/bin/bash DIR=$1 TABWIDTH=4 ( cd $DIR; for i in $( find -regex ".*\.\(c\|cpp\|cxx\|cc\|h\|\hpp\)" | sort ); do echo $i; expand -t$TABWIDTH $i | sed '${/^$/!s/$/\ /;}' | sed 's/\x0D$//' | sed 's/ *$//' > x; mv x $i; done ) git commit -am"Tidied $DIR. Replaced tabs with spaces, ensured each source file ends with a newline, replaced CRLF with LF, and removed trailing whitespace"