Skip to content

Instantly share code, notes, and snippets.

@shouichi
Created May 31, 2012 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shouichi/2846523 to your computer and use it in GitHub Desktop.
Save shouichi/2846523 to your computer and use it in GitHub Desktop.
#!/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