Chad K
asked on
Need to reformat a text file pattern into a different patterned output
I have a large text file that consists of the top 11 lines of a bunch of dns zone files. I need to parse this file and create a new file that generates a single line for every iteration of the pattern. Essentially the pattern consists of 11 lines, followed by a domain line and then repeats. For example, the pattern looks like the following:
This pattern repeats over and over for every domain name contained on our server. What I would like is to parse the file for each of these 11 lines and return the following:
domain2. SOA dauth5.domain.com. 2018020603 10800 3600 604800 10800
The "domain2" above comes from line 11 each time. Can anyone write a script or perhaps a quick way in Notepad++ to get the data formatted the way I want? Thanks!
; *** This file is automatically generated by Plesk ***
$TTL 86400
@ IN SOA dauth5.domain.com. contact.domain2.com. (
2018020603 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
10800 ) ; Minimum
---------------domain2.com
This pattern repeats over and over for every domain name contained on our server. What I would like is to parse the file for each of these 11 lines and return the following:
domain2. SOA dauth5.domain.com. 2018020603 10800 3600 604800 10800
The "domain2" above comes from line 11 each time. Can anyone write a script or perhaps a quick way in Notepad++ to get the data formatted the way I want? Thanks!
ASKER
Sorry, I messed up a bit...that line should be the whole domain.com followed by a "." This part should be pulled form the line 11 and always follows 15 "-" marks. Space delimited is just fine as well.
Easy enough to fix, but first another question: does the domain in this line already have a "." at the end (that maybe got edited away), or does the "." need to be explicitly added?
ASKER
no, the . needs to be added to the end of the domain from line 11 each time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome! Thanks!
Do you need the output just space separated, or as fixed column width (and if so, which width for which column?)
How exactly is the domain name generated? Just by cutting of .com, or the element after the last "."?
Open in new window