bash in-place replace dashes only on 1st column of a file


I have a file which contains 2 columns as follows:

some-app-name1     feature/branchname  
another-app-name1  feature-branch-name  
some-app-name2     hotfix-branch-name  
frontend-app-name  branchname  
another-app-name2  main-branch-name  

Using awk or sed I want to replace dashes and make next letter uppercase but only in first column of this file so the end
ouput will look like this:

someAppName1     feature/branchname  
anotherAppName1  feature-branch-name  
someAppName2     hotfix-branch-name  
frontendAppName  branchname  
anotherAppName2  main-branch-name  

Tried the following sed, but it replaces all the dashes in the file:
sed -E -i 's/-(.)/\u\1/g'

Any ideas on how this can be accomplished?

>Solution :

Presuming you’re using GNU sed, here is one way:

sed -E ':l; s/^(\S*)-(.)/\1\u\2/; tl'

Leave a ReplyCancel reply