Created
December 12, 2012 17:15
-
-
Save fallwith/4269687 to your computer and use it in GitHub Desktop.
Shell method to clean up source code
This file contains hidden or 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
# 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