ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hi all, this request essentially illustrates my weakness with shell scripts. I have a script that reads in a string that will be in CamelCase and I want to convert the value into first lowercase and then uppercase with an underscore inserted at each Capital letter, after the first appearance, hence:
I'm sure that there is an easy way to do this in bash, but I need someone to help me find it, many thanks.
You're right! Folding case is in the latest bash as documented here (scroll down to the last expansions). IDK which version it's in, maybe 4+?
It is indeed a 4.x feature, however it's not useful for going from TestCaseVariable to test_case_variable. The problem is in inserting the _ properly. It is, however, useful for going from test_case_variable to TEST_CASE_VARIABLE.