Skip to content

Instantly share code, notes, and snippets.

@TyeolRik
Last active May 24, 2023 01:09
Show Gist options
  • Save TyeolRik/f319f1c0fa23208bb15117ea6a193cb4 to your computer and use it in GitHub Desktop.
Save TyeolRik/f319f1c0fa23208bb15117ea6a193cb4 to your computer and use it in GitHub Desktop.
function camelcase_to_snakecase() {
local ret
ret=$(echo "$1" | sed -r 's/([A-Z])/_\L\1/g' | sed 's/^_//')
echo "$ret"
}
SomeString="helloWorldMyFriend"
snake_case=$(camelcase_to_snakecase "${SomeString}")
echo $snake_case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment