I can't seem to figure out something with awk.
When I type:
awk '/^[0-9]{5}/{print $1}' filename
it will only print lines that begin with 5 numeric characters.
When I type:
awk '/^[0-9]{5}/{if ($4 !~ "[A-Z]$") $4 = "X"}{print substr($2,1,1), substr ($4,1,1), substr ($3,1,1)}' filename
it prints lines all lines, even if they do not begin with 5 numeric characters.
Can someone please explain why the second example doesn't just print the lines that begin with 5 numeric characters?
Any help would be greatly appreciated.
Thanks,
John
When I type:
awk '/^[0-9]{5}/{print $1}' filename
it will only print lines that begin with 5 numeric characters.
When I type:
awk '/^[0-9]{5}/{if ($4 !~ "[A-Z]$") $4 = "X"}{print substr($2,1,1), substr ($4,1,1), substr ($3,1,1)}' filename
it prints lines all lines, even if they do not begin with 5 numeric characters.
Can someone please explain why the second example doesn't just print the lines that begin with 5 numeric characters?
Any help would be greatly appreciated.
Thanks,
John