bug-bash
[Top][All Lists]
Advanced

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

Re: Exclamation mark when using character classes


From: Ilkka Virta
Subject: Re: Exclamation mark when using character classes
Date: Sat, 21 Aug 2021 14:25:41 +0300

What do you get with [![:digit:]] then? It seems to work the same with both
! and ^ here:

$ now=$EPOCHREALTIME
$ echo "${now%[^[:digit:]]*}" "${now#*[^[:digit:]]}"
1629544775 183030
$ echo "${now%[![:digit:]]*}" "${now#*[![:digit:]]}"
1629544775 183030




On Fri, Aug 20, 2021 at 10:30 PM hancooper via Bug reports for the GNU
Bourne Again SHell <bug-bash@gnu.org> wrote:

> I am using EPOCHREALTIME and then computing the corresponding human
> readable form, that can handle
> changes in locale
>
> now=$EPOCHREALTIME
> printf -v second '%(%S)T.%s' "${now%[^[:digit:]]*}" "${now#*[^[:digit:]]}"
> printf -v minute '%(%M)T' "${now%[^[:digit:]]*}"
> printf -v hour '%(%H)T' "${now%[^[:digit:]]*}"
>
> Incidentally, [![:digit:]] does not work there, you need to use the
> POSIX-specified caret (^) instead of an
> exclamation mark when using character classes. I'm not sure if this is
> intentional or a bug in bash; man
> page doesn't seem to mention it.


reply via email to

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