Skip to content

Instantly share code, notes, and snippets.

@lephuongbg
Last active December 20, 2015 22:49
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 lephuongbg/6208228 to your computer and use it in GitHub Desktop.
Save lephuongbg/6208228 to your computer and use it in GitHub Desktop.
Expand tabs into 4 spaces
#!/bin/bash
if [ $# -lt 1 ]; then
find . -type f \( -name '*.xml' -o -name '*.php' -o -name '*.css' -o -name '*.html' -o -name '*.js' \) -exec sh -c 'expand -t 4 "$1" > _tmp_ && mv _tmp_ "$1"' - {} \;;
if [ $? == 0 ]; then
echo "Expanded tabs in `pwd`";
fi
else
for arg
do
find $arg -type f \( -name '*.xml' -o -name '*.php' -o -name '*.css' -o -name '*.html' -o -name '*.js' \) -exec sh -c 'expand -t 4 "$1" > _tmp_ && mv _tmp_ $1' - {} \;;
if [ $? == 0 ]; then
echo "Expanded tabs in `pwd`/$arg";
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment