Skip to content

Instantly share code, notes, and snippets.

@franzejr
Last active April 5, 2017 21:30
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 franzejr/9d42f6298c85bff0659c to your computer and use it in GitHub Desktop.
Save franzejr/9d42f6298c85bff0659c to your computer and use it in GitHub Desktop.
Removing trailing whitespace recursively from your project
#Removing trailing whitespace from .rb files
find -name '*.rb' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i
#Removing trailing whitespace from .erb files
find -name '*.erb' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i
# WORKING ON OSX
find . \( -name '*.rb' -or -name '*.js' -or \\n-name '*.css' -or -name '*.scss' -or -name '*.erb' -or -name '*.yml' -or -name '*.erb' \) \\n-print0 | xargs -0 sed -i '' -E "s/[[:space:]]*$//"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment