Skip to content

Instantly share code, notes, and snippets.

@NickStemerdink
Created August 1, 2013 23:18
Show Gist options
  • Save NickStemerdink/6136215 to your computer and use it in GitHub Desktop.
Save NickStemerdink/6136215 to your computer and use it in GitHub Desktop.
sed camel case to underscore
Command: sed -e 's/\([A-Z]\)/_\l\1/g' -e 's/^_\([a-z]\)/\1/g'
$ echo foo | sed -e 's/\([A-Z]\)/_\l\1/g' -e 's/^_\([a-z]\)/\1/g'
$ echo Foo | sed -e 's/\([A-Z]\)/_\l\1/g' -e 's/^_\([a-z]\)/\1/g'
$ echo SuperFooBar | sed -e 's/\([A-Z]\)/_\l\1/g' -e 's/^_\([a-z]\)/\1/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment