help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One expression to get the first letter of a string and capitalize it


From: Peng Yu
Subject: Re: One expression to get the first letter of a string and capitalize it
Date: Tue, 24 Aug 2021 13:05:58 -0500

But I just want to get the first letter.

On 8/24/21, Dennis Williamson <dennistwilliamson@gmail.com> wrote:
> On Tue, Aug 24, 2021, 8:01 AM Peng Yu <pengyu.ut@gmail.com> wrote:
>
>> x=abc
>> y=${x:0:1}
>> echo "${y^^}"
>>
>> I want to get the first letter of a string and capitalize it. Ideally,
>> I want it to be done in one expression. But I only know how to do it
>> with two expressions.
>>
>> Is there a way to do it in a more concise manner (without using an
>> extra variable, or definition of a new function, etc)?
>>
>> --
>> Regards,
>> Peng
>>
>
>
> Use one carat instead of two.
>
> echo "${x^}"
>
>>
>


-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]