Created
June 14, 2019 02:33
-
-
Save vitorhugomattos/e939c90171bdc0863cfb7c7732cb30df to your computer and use it in GitHub Desktop.
Converter indentação de espaços para tabs em todo projeto (pasta e subpastas)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -n $1 ] | |
then | |
directory="$1" | |
else | |
directory="." | |
fi | |
while read -r -d "" file; do | |
tmpfile=$(mktemp /tmp/tempfile.XXXXXX) | |
echo "Convertendo arquivo: $file" | |
unexpand -t 4 "$file" > "$tmpfile" | |
cp --preserve=all --attributes-only -- "$file" "$tmpfile" # só deve funcionar com o cp do GNU | |
mv -f -- "$tmpfile" "$file" | |
done < <(find "$directory" -type d -path '*/\.*' -prune -o -not -name '.*' -type f -print0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment