Reputation: 25
I'm trying to parse a text file with an awk one liner and:
Example data:
Name Type Data Timestamp
(same as parent folder) Start of Authority (SOA) [69671], server1.abc.com., hostmaster.abc.com. static
(same as parent folder) Name Server (NS) server2.abc.com. static
access Host (A) 192.168.99.190 static
apps Host (A) 192.168.99.181 static
I'm able to do 1 & 3, but my regex must be off for the '(' match:
awk -F$'\t' 'NR > 1' | awk '!/^(/' '{print toupper($1),$2,$3}' test.txt > out.txt
awk: cmd. line:1: error: Unmatched ( or (: /^(/
I tried escaping the open parenthesis but that didn't work either. I started pipelining the second awk
because I thought the NR
filter was getting in the way, but it's obvious I'm missing something (probably basic).
Upvotes: 0
Views: 353
Reputation: 204638
$ awk 'BEGIN{FS=OFS="\t"} NR>1 && !/^\(/{print toupper($1), $2, $3}' file
ACCESS Host (A) 192.168.99.190
APPS Host (A) 192.168.99.181
Upvotes: 1