Skip to content

Instantly share code, notes, and snippets.

@vitorhugomattos
Created June 14, 2019 02:33
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 vitorhugomattos/e939c90171bdc0863cfb7c7732cb30df to your computer and use it in GitHub Desktop.
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)
#!/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