Skip to content

Instantly share code, notes, and snippets.

@reagent
Last active August 15, 2019 03:27
Show Gist options
  • Select an option

  • Save reagent/e1f8b4ccaaa659b4ae76 to your computer and use it in GitHub Desktop.

Select an option

Save reagent/e1f8b4ccaaa659b4ae76 to your computer and use it in GitHub Desktop.
Convert whitespace from tabs to 2 spaces
#!/bin/bash
set -e # fail on nonzero status
cd $1
files=`find . -path ./vendor -prune -type f \
-name '*.html' -o -name '*.js' -o -name '*.coffee' -o \
-name '*.sass' -o -name '*.scss' -o -name '*.erb'`
for file in $files; do
echo -n "Converting '$file' ... "
expand -t2 $file > out.tmp
mv out.tmp $file
echo 'done.'
done
git add .
git commit -m "Convert whitespace"
@efatsi
Copy link

efatsi commented Aug 20, 2014

rm out.tmp at the end perhaps?

@reagent
Copy link
Author

reagent commented Aug 20, 2014

mv will remove it

@nhunzaker
Copy link

Worth adding -not \( -path ./node_modules -prune \) \

@tommymarshall
Copy link

☝️ what he said.

@reagent
Copy link
Author

reagent commented Sep 5, 2014

got it -- rm -rf ./node_modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment