Reputation: 740
I am trying to convert camelcase string into lower and underscore case, I don't know many bash commands and I couldn't find anything, if this doesn't take big time for you, please give me example. like: 'TestCamelCase' -> result should be 'test_camel_case'. thank you in advanced!
Upvotes: 5
Views: 2843
Reputation: 4162
Here's an approach that avoids the need for GNU sed extensions and works on macOS:
$ echo 'TestCamelCase' | sed 's/[[:upper:]]/_&/g;s/^_//' | tr '[:upper:]' '[:lower:]'
test_camel_case
Upvotes: 5