title: linux shell title case
body: <p>I am wrinting a shell script and have a variable like this: <code>something-that-is-hyphenated</code>.</p>
  
  <p>I need to use it in various points in the script as:</p>
  
  <p><code>something-that-is-hyphenated</code>, <code>somethingthatishyphenated</code>, <code>SomethingThatIsHyphenated</code></p>
  
  <p>I have managed to change it to <code>somethingthatishyphenated</code> by stripping out <code>-</code> using <code>sed "s/-//g"</code>.</p>
  
  <p>I am sure there is a simpler way, and also, need to know how to get the camel cased version.</p>
  
  <p>Edit: Working function derived from @Michał's answer</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Edit: Finally, a sed one liner thanks to @glenn</p>
  
  <pre><code>echo a-hyphenated-string | sed -E "s/(^|-)([a-z])/\u\2/g"
  </code></pre>