This is a continuation of this question perhaps:
How to remove trailing whitespace of all files recursively?
I want to only remove whitespace for html / css / sass / whatever files I want.
Edit: whoops. I'm on Mac OS X Lion
This worked for me to remove trailing whitespaces or tabs from all files in the ( ... ) section:
find . -type f \( -name "*.css" -o -name "*.html" -o -name "*.sass" \) -exec perl -p -i -e "s/[ \t]*$//g" "{}" \;
If you only want to remove whitespaces (and not tabs), then change s/[ \t]*$//g
for s/ *$//g
If you want to change anything else, then just adjust the regex search and replace patterns to your liking. You should change the starting path of find to whatever path you want too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With