Created
April 29, 2017 16:05
-
-
Save dongkwan-kim/abe66a5317630e7718979106ee985d78 to your computer and use it in GitHub Desktop.
shell script to change snake_case to camelCase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
echo "$string" | sed -r 's/([A-Za-z])(^|_)(\w)/\1\U\3/g'
Idea: https://stackoverflow.com/a/34420162/1041470
- Unlimited number of underscores could be used.
- First char is lower case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To treat names like host1_ip, I'd propose to use this regex: