Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 Inserted a missing hyphen in "0-9". Then did a trivial rewording because it requires 6 chars to be changed 8-)
source | link

I would modify your own solution. Instead of deleting any $1 that doesn't match the required regexp, use grep to filter them out: 

awk '{print $1}' /tmp/test | grep -iE '^[a-z0-9]{12}$'

Another alternativeAlternatively in pure sed:

sed 's/^\([a-zA-Z09]\Z0-9]\{12\}\)[ \t]\+.*/\1/' /tmp/test     

I would modify your own solution. Instead of deleting any $1 that doesn't match the required regexp, use grep to filter them out:

awk '{print $1}' /tmp/test | grep -iE '^[a-z0-9]{12}$'

Another alternative in pure sed:

sed 's/^\([a-zA-Z09]\{12\}\)[ \t]\+.*/\1/' /tmp/test

I would modify your own solution. Instead of deleting any $1 that doesn't match the required regexp, use grep to filter them out: 

awk '{print $1}' /tmp/test | grep -iE '^[a-z0-9]{12}$'

Alternatively in pure sed:

sed 's/^\([a-zA-Z0-9]\{12\}\)[ \t]\+.*/\1/' /tmp/test     
1
source | link

I would modify your own solution. Instead of deleting any $1 that doesn't match the required regexp, use grep to filter them out:

awk '{print $1}' /tmp/test | grep -iE '^[a-z0-9]{12}$'

Another alternative in pure sed:

sed 's/^\([a-zA-Z09]\{12\}\)[ \t]\+.*/\1/' /tmp/test