Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to capitalize last character of a string?



On 26 October 2010 13:56, AndrÃs Nemes <andras.nemes@xxxxxxxxx> wrote:
> nearly there.
>
> print "$TEST[1,-2]${(C)TEST[-1]}"
>
> On Tue, Oct 26, 2010 at 10:42 PM,  <nix@xxxxxxxxxxxxxxxx> wrote:
>> Hi, as the subject says, any guidance?
>>
>> TEST="word"
>>
>> print "${(C)TEST[1]}$TEST[2,-1]"
>>
>> Capitalizes the first character but somehow I could not come up with
>> solution other way.

And if for some reason you want to capitalize the last letter of every
word in a sentence (really, when don't you want to do that?),

% TEST="this is a sentence"
% echo ${(j::)${(@Oa)${(s::)${(Cj::)${(@Oa)${(s::)TEST}}}}}}
thiS iS A sentencE

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author