Skip to content

Instantly share code, notes, and snippets.

@tancredi
Last active December 14, 2016 15:23
Show Gist options
  • Save tancredi/96f8ef4784386bd3895def96cfe4a093 to your computer and use it in GitHub Desktop.
Save tancredi/96f8ef4784386bd3895def96cfe4a093 to your computer and use it in GitHub Desktop.
#!/bin/bash
###################################################################
## Usage: ./indent_4_to_2_spaces.sh lib/**/*.js www/css/**/*.css ##
###################################################################
echo Re-indenting ${$#-2} files from 4 to 2 spaces...
for (( i=1; i<=$#; i++ )); do
sed -e 's/^/~/' -e ': r' -e 's/^\( *\)~ /\1 ~/' -e 't r' -e 's/~//' ${!i} > ${!i}.tmp && mv ${!i}.tmp ${!i}
echo Re-indented ${!i}.
done
@missinglink
Copy link

missinglink commented Dec 14, 2016

@tancredi what about this?

find -name "*.js" | xargs sed -i "s/    /  /g"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment