Skip to content

Instantly share code, notes, and snippets.

@seanf
Created October 1, 2013 01:54
Show Gist options
  • Save seanf/6772919 to your computer and use it in GitHub Desktop.
Save seanf/6772919 to your computer and use it in GitHub Desktop.
Remove whitespace errors
#!/bin/bash
# Remove trailing whitespace per line
sed -i 's/[ \t]*$//' "$@"
#http://stackoverflow.com/questions/7359527/removing-trailing-starting-newlines-with-sed-awk-tr-and-friends
# Delete all trailing blank lines at end of file (only).
sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment