Den 2021-07-07 kl. 00:09 skrev John Ankarström:
> In any case, the POSIX-compatible equivalent is
>
>    echo .ds head-str `printf %s "$str" | tail -c1`

Ah! There is a simpler solution:

   echo .ds head-str ${str#"${str%?}"}

Now that's elegant... and POSIX-compatible.

Note the necessary quotation marks around ${str%?}
(in case $str contains glob characters).


Reply via email to