How to remove trailing whitespace from a bunch of files

Linux files (and also Mac)

find . -name '*.js' -exec sed -i 's/[[:blank:]]*\n$/\n/g' '{}' \;

Windows files

find . -name '*.js' -exec sed -i 's/[[:blank:]]*\r$/\r/g' '{}' \;

Sed oneliners

http://sed.sourceforge.net/sed1line.txt


Published 7th Feb 2011 // #debian #tips




comments powered by Disqus