When using git to maintain versions of XCode4 projects, often we need to "delete trailing whitespace" before we add or commit file to the git tree. While XCode4 leaves lots of line with trailing white spaces. How to remove them?
By Bash commands :
find -E . -type f -regex ".*\.(h|m|mm)" -print0 | xargs -0 sed -i -E "s/[[:space:]]*$//"
Note:
-E for find: Interpret pattern after -regex with Extended Regular Expression(ERE) syntax, should be placed before {directory}
".*\.(h|m|mm)" : match file name with .h, .m, .mm at the end, which is ERE syntax.
-E for sed: Interpret pattern using ERE syntax, the [:sapce:] represents the Whitespace character set: [ \t\r\n\v\f]
Thus, we can delete trailing white space with one command line in the project top directory ! Simple and clear !
沒有留言:
張貼留言