Skip to content

Instantly share code, notes, and snippets.

@bluemanos
Last active August 29, 2015 14:11
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 bluemanos/af3e36a3343bf3a3260f to your computer and use it in GitHub Desktop.
Save bluemanos/af3e36a3343bf3a3260f to your computer and use it in GitHub Desktop.
Convert tabs to spaces in PHP/HTML/CSS/TXT files
#!/bin/sh
# script to convert tabs to spaces in PHP files
# usage: ./expand /path/to/project/directory
echo $(date)
path=${1:-.}
for f in $(find "$path" -type f -name \*.php -o -name \*.html -o -name \*.css -o -name \*.txt -o -name \*.js)
do
oryginal_file=`cat "$f"`
expanded_file=`expand -i -t4 "$f"`
if [ "$oryginal_file" != "$expanded_file" ]; then
echo "$expanded_file" > "$f"
fi
done
echo $(date)
#!/bin/sh
# script to convert spaces to tabs in PHP files
# usage: ./unexpand /path/to/project/directory
echo $(date)
path=${1:-.}
for f in $(find "$path" -type f -name \*.php -o -name \*.html -o -name \*.css -o -name \*.txt -o -name \*.js)
do
oryginal_file=`cat "$f"`
unexpanded_file=`unexpand -t4 "$f"`
if [ "$oryginal_file" != "$unexpanded_file" ]; then
echo "$unexpanded_file" > "$f"
fi
done
echo $(date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment