I try to capitalize the first letter in a CSV which is sorted like this:
a23;asd23;sdg3
What i want is a output like this
a23;Asd23;Sdg3
So the first String should be as is, but the second and third should have a capitalized first letter. I tried with AWK and SED but i didn't find the right solution. Can someone help?
Use ^ to convert the first letter to uppercase and ^^ to convert all characters to uppercase. Use , to convert the first letter to lowercase and ,, to convert all characters to lowercase. Use ~ to toggles the case for the first character and ~~ to toggle cases for all characters.
@CMCDragonkai: To lowercase the first letter, use "${foo,}" . To lowercase all the letters, use "${foo,,}" . To uppercase all the letters, use "${foo^^}" .
To capitalize the first character of a string, We can use the charAt() to separate the first character and then use the toUpperCase() function to capitalize it.
The ^ operator converts to uppercase, while , converts to lowercase. If you double-up the operators, ie, ^^ or ,, , it applies to the whole string; otherwise, it applies only to the first letter (that isn't absolutely correct - see "Advanced Usage" below - but for most uses, it's an adequate description).
Just capitilise all letters that follow a semicolon:
sed -e 's/;./\U&\E/g'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With