Last active
September 4, 2015 07:15
-
-
Save eik3/283693 to your computer and use it in GitHub Desktop.
fix whitespace problems in source tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this find command lists all text files excluding files (e.g. binary files) that shouldn't be touched. | |
# you might want to add more file name extensions for your project if [1] outputs extensions of files | |
# that you don't want to have processed | |
# | |
# the commands below were tested on Ubuntu, your milage may vary on Mac OS (please leave a comment if so) | |
find . -regextype posix-extended -type f -size +0 ! -iregex '.*/\.(svn|git)/.*' ! -iregex '.*\.(gif|png|jpe?g|ico|psd|ai|jar|db|odt|pdf|swf|rtf|zip|eps|sqlite3?|mo|air|mp3|wav|otf|eot|ttf|woff)$' | |
# append this to add missing newline at EOF | |
-print0 | xargs -0 printf "e %s\nw\n" | ed -s; | |
# or append this to fix trailing whitespace | |
-exec sed -i 's/[ \t]*$//' '{}' ';' | |
# or append this to replace tabs with two spaces | |
-exec sed -i 's/\t/ /g' '{}' ';' | |
# [1] append this to list all filename extensions | |
-printf '%f\n' | sed -r 's/(.*)\.([^\.]+)$/\2/i' | LC_COLLATE=C sort | uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment