# Change '*.cpp' and '*.h' to the extension you want to remove whitespaces in. find -name '*.cpp' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i find -name '*.h' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i