bug-bash
[Top][All Lists]
Advanced

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

Exclamation mark when using character classes


From: hancooper
Subject: Exclamation mark when using character classes
Date: Fri, 20 Aug 2021 19:28:25 +0000

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]