Created
February 21, 2013 16:57
-
-
Save mauritsvanrees/5006200 to your computer and use it in GitHub Desktop.
Nuke trailing white space in several types of file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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