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

Re: How to capitalize last character of a string?



On Tue, Oct 26, 2010 at 2:42 PM,  <nix@xxxxxxxxxxxxxxxx> wrote:
> Thanks. Sorry for duplicate question (i sent earlier this same question
> and some other gave a solution). It works yes.
>
> I am really having trouble with these modifiers. Last question: How to
> apply both macros (Capitalize the first and the last letter) ?
>
> [CapitaL]
>
> So the result would be: WorD

I'm pretty new to brace expansion myself, but by looking at your code
I figured it out:

TEST=word
print ${(C)TEST[1]}$TEST[2,-2]${(C)TEST[-1]}

output: WorD

-Linus



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