Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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'

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading