Skip to main content

How to remove trailing whitespace from a bunch of files

·44 words·1 min

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