Created
November 24, 2021 23:25
-
-
Save amiralles/3e1f8a9db9dd58d10f3112f910910cd1 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Converts camelCased words into snake_cased ones. | |
# (This might be seful when you have to convert a JS object into an Elixir one.) | |
# TODO: Ignore quoted strings. | |
function camel_to_snake_case { | |
while read -r line; do | |
echo $line | sed 's/\(.\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]' | |
done | |
} | |
camel_to_snake_case |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment