I'm trying to achieve the following.
Find first '(' symbol (always located at the start of a new line) in a text file and make the hostname that follows a variable such as '(host' becomes 'host'.
Copy text between first instance of '=-=-=' delimiter and second instance of the same delimiter ('=-=-=') to a new file whose name is the variable in item 1 such as host-messages.txt
Copy text between second instance of '=-=-=' delimiter and third instance of the same delimiter to a new file whose name is the variable in item 1 such as host-df.txt
Copy text between third instance of '=-=-=' delimiter and subsequent next instance of a '(' on the first character of a new line such as the next instance of a '(hostname',to a new file whose name is the variable in item such as host-dfa.txt
Repeat steps 1 through 4 until end of file and no more '(host' are found.
Anyway what I'm trying to achieve is extract data such as:
(hostname1 : 056603) Â 1
=-=-=
TEXT
TEXT
TEXT
=-=-=
TEXT2
TEXT2
TEXT2
=-=-=
TEXT3
TEXT3
TEXT3
(hostname2
=-=-=
etc...
Newly created files should be hostname1-messages.txt, hostname1-df.txt and hostname1-dfa.txt.
The best I've come up with so far is
awk '/=-=-=/{x="F"++i;next}{print > x;}' test.txt
but it's not working.