Skip to content

Instantly share code, notes, and snippets.

@artgillespie
Created November 24, 2011 20:52
Show Gist options
  • Save artgillespie/1392258 to your computer and use it in GitHub Desktop.
Save artgillespie/1392258 to your computer and use it in GitHub Desktop.
Remove trailing whitespace from all source files under the current dir
#!/bin/sh
#
# Removes trailing whitespace from all source files in the current directory and its children.
# Note the `-i .bak` switch to sed. This will create a backup copy alongside any modified files
# like `Somefile.cpp.bak` Simply remove the `.bak` argument to `-i` to prevent the backup
# files from being generated
#
/usr/bin/find . -type f -and \( -name '*.m' -or -name '*.h' -or -name '*.mm' -or -name '*.cpp' -or -name '*.c' \) -and -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]+$//"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment