manus
manus

Reputation: 41

AWK regex for matching dot character

I have just started learning AWK, and has a basic question. My file is very simple like below:

h24_outdrive_s0.mt0
h24_outdrive_s.mt0

So if I try "awk '$NF~/\d\.mt./' file", it should have matched first line. But doesn't match anything. Looks like issue is with matching a "." as a character.

Some basic stuff is missed out here? Please help.

Upvotes: 1

Views: 5693

Answers (1)

Kent
Kent

Reputation: 195219

use awk '$NF~/[0-9]\.mt./'

you will see the matched result.

btw, if your real file is just like this, you can just do awk '/[0-9]\.mt/' file. It does the line matching. in your file, $NF == $0

Upvotes: 3

Related Questions