I wring the shell script and have this variable: something-that-is-hyphenated .
I need to use it at different points in the script like:
something-that-is-hyphenated , somethingthatishyphenated , somethingthatishyphenated
I managed to change it to somethingthatishyphenated by deleting - using sed "s/-//g" .
I am sure there is an easier way, and you also need to know how to get the camel shell version.
Edit: working function derived from @ Michał's answer
function hyphenToCamel { tr '-' '\n' | awk '{printf "%s%s", toupper(substr($0,1,1)), substr($0,2)}' } CAMEL=$(echo something-that-is-hyphenated | hyphenToCamel) echo $CAMEL
Editing Finally, sed one liner thanks to @glenn
echo a-hyphenated-string | sed -E "s/(^|-)([az])/\u\2/g"
source share