Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upper- to lower-case on first column only in bash

Tags:

bash

How do I change in bash only the first column into lower case? for example: ABC|DEF|GHI to abc|DEF|GHI

thanks

like image 559
user1171632 Avatar asked Dec 04 '25 22:12

user1171632


2 Answers

echo "ABC|DEF|GHI" | sed 's/\([A-Z]*\)\|/\L\1/'

outputs:

abc|DEF|GHI

like image 157
Alex Avatar answered Dec 07 '25 14:12

Alex


awk -F"|" '{l = $0; sub($1, "", l); print tolower($1) l}' yourFile
like image 37
amit_g Avatar answered Dec 07 '25 14:12

amit_g



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!