Skip to content

Instantly share code, notes, and snippets.

@bluemanos bluemanos/expand
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.