Created
May 16, 2010 06:03
-
-
Save fallwith/402702 to your computer and use it in GitHub Desktop.
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
# Use Ack to find offending source files and Perl to perform the following: | |
# convert Windows newlines to unix newlines | |
# convert tabs to two spaces | |
# strip trailing whitespace | |
ack " +$|\t|\r" -l|xargs perl -pi -e "s/\r\n?/\n/g;s/\t/ /g;s/[ ]*$//g" | |
# Implement a clean() method in Bash: | |
# Clean up source code by converting tabs to 2 spaces, Windows newlines to | |
# unix ones, and by stripping away trailing whitespace. Pass in a list of | |
# files to clean, or let ack find a list of suitable candidates. | |
clean() { | |
if [ $1 ]; then | |
files=$@ | |
else | |
files=`ack " +$|\t|\r" -l` | |
fi | |
echo $files|xargs perl -pi -e "s/\r\n?/\n/g;s/\t/ /g;s/[ ]*$//g" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment