Created
May 31, 2012 21:43
-
-
Save shouichi/2846523 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Converts return character to '\n' and removes trailing spaces/lines. | |
if [ $# -ne 1 ] | |
then | |
echo $0 '<directory>' | |
exit 1 | |
fi | |
DIRECTORY=$1 | |
find $DIRECTORY -type f | xargs dos2unix | |
find $DIRECTORY -type f | xargs sed -i 's/[ \t]*$//g' | |
find $DIRECTORY -type f | xargs sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment