Skip to content

Instantly share code, notes, and snippets.

@eiskalteschatten
Last active July 14, 2018 07:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiskalteschatten/12596efee4978328d5b90f4a39d0916e to your computer and use it in GitHub Desktop.
Save eiskalteschatten/12596efee4978328d5b90f4a39d0916e to your computer and use it in GitHub Desktop.
Batch Convert 4-Space Indentations to 2-Space
#!/bin/bash
expand_func () {
OLD_LENGTH=4 # old indentation length
NEW_LENGTH=2 # new indentation length
unexpand -t $OLD_LENGTH "$1" | expand -t $NEW_LENGTH > "$1.tmp"
mv "$1.tmp" "$1"
}
export -f expand_func
find ./ -name \*.js -exec bash -c 'expand_func {}' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment