S
Steven Drenker
I've got clean up a large file comprised of returns from antispam DNSBL
servers. The data is comprised of records like those shown below (two full
records shown).
I want to remove all the lines EXCEPT the one starting ";; ANSWER SECTION:"
and the line(s) immediately that one. I want to resume deleting lines with
the next line after ANSWER SECTION starting with ";; res options:"
I was thinking of the following logic:
1. Position the cursor at the start of the file
2. Do the first 9 characters of the line match ";; ANSWER"
3. If no, delete the line
4. If yes, move cursor down until a match is found with ";; res options"
5. Resume deleting lines until the next match of ";; ANSWER"
Although this sounds conceptually simple, I can't come up with the code to
execute it.
Any help would be greatly appreciated!
Steve
- - - - - - - - - - - - - - - - - - - - - -
Two DNS records shown below. Delete everything but the two lines marked
"KEEP"
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15173
;; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUERY SECTION:
;; 218.0.249.210.bl.deadbeef.org, type = ANY, class = IN
;; ANSWER SECTION: <-- KEEP
218.0.249.210.bl.deadbeef.org. 1D IN A 69.6.215.63 <-- KEEP
;; res options: init recurs defnam dnsrch <-- RESTART DELETE
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54857
;; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUERY SECTION:
;; 218.0.249.210.blackhole.securitysage.com, type = ANY, class = IN
;; res options: init recurs defnam dnsrch
servers. The data is comprised of records like those shown below (two full
records shown).
I want to remove all the lines EXCEPT the one starting ";; ANSWER SECTION:"
and the line(s) immediately that one. I want to resume deleting lines with
the next line after ANSWER SECTION starting with ";; res options:"
I was thinking of the following logic:
1. Position the cursor at the start of the file
2. Do the first 9 characters of the line match ";; ANSWER"
3. If no, delete the line
4. If yes, move cursor down until a match is found with ";; res options"
5. Resume deleting lines until the next match of ";; ANSWER"
Although this sounds conceptually simple, I can't come up with the code to
execute it.
Any help would be greatly appreciated!
Steve
- - - - - - - - - - - - - - - - - - - - - -
Two DNS records shown below. Delete everything but the two lines marked
"KEEP"
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15173
;; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUERY SECTION:
;; 218.0.249.210.bl.deadbeef.org, type = ANY, class = IN
;; ANSWER SECTION: <-- KEEP
218.0.249.210.bl.deadbeef.org. 1D IN A 69.6.215.63 <-- KEEP
;; res options: init recurs defnam dnsrch <-- RESTART DELETE
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54857
;; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUERY SECTION:
;; 218.0.249.210.blackhole.securitysage.com, type = ANY, class = IN
;; res options: init recurs defnam dnsrch