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: Dennis Williamson
Subject: Re: One expression to get the first letter of a string and capitalize it
Date: Tue, 24 Aug 2021 08:10:53 -0500

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^}"

>


reply via email to

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