bash - Awk regex for a string of exact length that ends in ":" -


i can't regex right:

awk '$6 ~ /:${14}/ {print $6}' file 

i need print out 6th field if it's 15 characters long , ends ":".

here's example: oafkq7xs001224:

you need use --posix as:

awk --posix '{ if ($6 ~ /^.{14}:$/) print $6}' file 

command in action

from awk manual page:

interval expressions available if either --posix or --re-interval specified on command line.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -