When it comes to source code, i am a perfectionist. I cant stand to see trailing whitespace, interchanged tabs/spaces, etc.
This Stackoverflow user asked How To Remove Trailing Whitespace Of All Files Recursively.
This reply helped me to work around the fact that \s and \t are not supported in the mac version of sed:
find dir -type f -print0 | xargs -0 sed -i .bak -E “s/[[:space:]]*$//”
So using [:space:] can actually work for both tabs and spaces.
However, I ended up not using ‘find’ for the files, and then passing the files to sed directly:
sed -i ” ‘s/[[:space:]]*$//g’ **/*.*