I'm having trouble using quantifier in a Awk Regex.
awk -F"|" -v col="$COUNTER" '$col ~ /doi\/tm-[a-z0-9]/ { print $col } ' OFS=, tmp.csv
This works fine, but I want to specify to the [a-z0-9] class a limit of 8 chars.
So I did :
awk -F"|" -v col="$COUNTER" '$col ~ /doi\/tm-[a-z0-9]{8}/ { print $col } ' OFS=, tmp.csv
It doesn't work, and :
awk -F"|" -v col="$COUNTER" '$col ~ /doi\/tm-[a-z0-9]\{8\}/ { print $col } ' OFS=, tmp.csv
doesn't work neither.
That's on a Ubuntu 20.04 system.
awk
implementation are you using? What Unix are you running on? Possibly related: unix.stackexchange.com/questions/561772/… – Kusalananda♦ Oct 16 '20 at 14:30mawk
by default which is not POSIX compliant and doesn't support regex interval operators (doesn't support POSIX character classes nor multibyte characters either). You can installgawk
which should replacemawk
withgawk
forawk
. Alternatively you could runbusybox awk
instead ofawk
. – Stéphane Chazelas Oct 16 '20 at 14:39