Reputation: 75
I'm trying to replace _[lowercase] to [uppercase] using sed in bash.
So far I've tried this code:
new_arr=$( echo $old_arr | sed -e 's%_\(.\)%\1\U%g' )
With input of
this_is_a_function()
i expected the output to be
thisIsAFunction()
but i got
thisisafunction
Do you have a suggestion for what I might be doing wrong?
Upvotes: 1
Views: 725
Reputation: 133428
Could you please try following.
sed 's/_\([a-z]\)/\U\1/g' Input_file
So in OP's case it should be something like:
new_arr=$( echo "$old_arr" | sed 's%_\([a-z]\)%\U\1%g' )
Upvotes: 3