81235
81235

Reputation: 179

how to match the character start with and end with in awk

I am using awk. I have several names like

rs123123789_G    rs9888_A     rs23789_GA rs23789_GASDFAS

I want to find the name start with rs and end with single character in awk (rs123123789_G, rs9888_A). I tried use

~/^rs[0-9]+[A-Z]$/

But it does not work.

Upvotes: 0

Views: 316

Answers (1)

SLePort
SLePort

Reputation: 15461

You're missing the underscore :

~/^rs[0-9]+_[A-Z]$/

All the 3 names in your example are starting with rs and all are ending with a single alphabetic character - G, A, S respectively. Your requirement is that they should end with single alphabetic character after _.

Upvotes: 2

Related Questions