Skip to content

Instantly share code, notes, and snippets.

@dongkwan-kim
Created April 29, 2017 16:05
Show Gist options
  • Save dongkwan-kim/abe66a5317630e7718979106ee985d78 to your computer and use it in GitHub Desktop.
Save dongkwan-kim/abe66a5317630e7718979106ee985d78 to your computer and use it in GitHub Desktop.
shell script to change snake_case to camelCase
#! /bin/bash
# usage bash toCamel.sh target.js
# snake_func -> snakeFunc
for i in $(seq 1 30)
do
cat $1 | sed -r 's/([a-z]+)_([a-z])([a-z]+)/\1\U\2\L\3/g' > temp
mv temp $1
done
@ipotseluev
Copy link

To treat names like host1_ip, I'd propose to use this regex:

's/([0-z]+)_([0-z])([0-z]+)/\1\U\2\L\3/g'

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