[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: utmac -muh error on Ubuntu
From: |
John Ankarström |
Subject: |
Re: utmac -muh error on Ubuntu |
Date: |
Wed, 7 Jul 2021 00:09:11 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
Den 2021-07-05 kl. 16:07 skrev Tadziu Hoffmann:
>
>>> echo ".ds head-str ${str: -1}"
>
>> The compatible syntax is ${str:-1}.
>
> I wonder if that is meant, though.
>
> Bash also has
>
> ${parameter:offset}
> ${parameter:offset:length}
> Substring Expansion. Expands to up to length characters of
> the value of parameter starting at the character specified
> by offset.
Aha, I see. That seems a bit dangerous...
In any case, the POSIX-compatible equivalent is
echo .ds head-str `printf %s "$str" | tail -c1`
Unfortunately not as elegant as the reverse operation (${x%?}).