Skip to content

Instantly share code, notes, and snippets.

@mauritsvanrees
Created February 21, 2013 16:57
Show Gist options
  • Save mauritsvanrees/5006200 to your computer and use it in GitHub Desktop.
Save mauritsvanrees/5006200 to your computer and use it in GitHub Desktop.
Nuke trailing white space in several types of file.
#! /bin/sh
echo "Nukes all trailing white space in *pt and *py and some other files."
FOR_REAL=0
if test $# -eq 1; then
if test $1 = "-y"; then
FOR_REAL=1
fi
fi
if test $FOR_REAL -eq 1; then
echo "This is for real."
else
echo "This is NOT for real. Use -y to really nuke the white space."
fi
for i in $(find . -type f -name '*p[yt]' -o -name '*.zcml' -o -name '*.xml'); do
COUNT=$(grep -c " *$" $i)
if test $COUNT -ne 0; then
if test $FOR_REAL -eq 1; then
cat $i | sed "s| *$||" > dummy
mv dummy $i
else
echo "Will change: $COUNT $i"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment