1.Install brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.Install gnu-sed replace the sed on mac
brew install gnu-sed --with-default-names
3.Use sed
Example (for python files):
Make only one space before and after '='
sed -i 's/\s\+=\s\+/ = /g' *.py
Make only one space after ','
sed -i 's/\s*,\s*/, /g' *.py