Last active
December 11, 2015 22:59
-
-
Save wildlyinaccurate/4673915 to your computer and use it in GitHub Desktop.
Convert tabs to 4 spaces and trim any trailing whitespace
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 requires GNU sed (or any sed which supports -i) and expand | |
find . -type f -printf "sed -i 's/[ \t]*$//' %p && expand -t 4 %p > %p.tmp && mv %p.tmp %p\n" | sh | |
# It's better to be more specific about which files you want to run the replacement in, e.g. | |
find . -type f -name *.php -printf "sed -i 's/[ \t]*$//' %p && expand -t 4 %p > %p.tmp && mv %p.tmp %p\n" | sh | |
# You can use find's -regex option to match multiple extensions (you need to double-escape backslashes in bash): | |
find . -type f -regex .+\\\.\\\(php\\\|css\\\|js\\\)\$ -printf "sed -i 's/[ \t]*$//' %p && expand -t 4 %p > %p.tmp && mv %p.tmp %p\n" | sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment