Fix whitespace

#!/bin/sh
EXTENSIONS="sh|txt|php|py|rb|css|js|html|xsl|xml|sql"
for file in `find -type f | grep -v "\.svn" | grep -E "($EXTENSIONS)$"`
do
    # Send the commands H and w to ed
    # ed will append newline if the file does not end in one
    printf "%s\n" H w | ed -s $file
 
    # Strip trailing whitespace
    sed -i 's/[ \t]*$//g' $file
 
    # Convert tabs to 4 spaces
    sed -i -r "s/\t/    /g" $file
done