Skip to content

Instantly share code, notes, and snippets.

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