# Strip trailing whitespace from files that end in .as.
# Change this to match your programming language.
# I'm not sure if the -i flag is supported by all OSs.
find . -name '*.as' | xargs sed -i 's/ *$//g'
# See if the changes look reasonable.
git diff
# There should be no changes that aren't whitespace changes.
git diff -w
Thursday, September 30, 2010
Tailing Whitespace
Here's how to get rid of trailing whitespace from all your files:
Subscribe to:
Post Comments (Atom)


2 comments:
Thanks JJ,
Here's my tweaks for use outside of repositories where undoing changes isn't so easy:
file_ext="py"
find . -name "*$file_ext" | xargs sed -i_$(date +%Y%m%d%H%M) 's/ *$//g'
Where file_ext is the extension of the files you want to operate on. _$(date +%Y%m%d%H%M) will ask sed to make a backup of the original file with a timestamp appended to the name.
Eric.
Yep, very good.
Post a Comment