Hi Experts,
I have to split huge file based on the pattern to create smaller files. The pattern which is expected in the file is:
Master.....
First...
second....
second...
third..
third...
Master...
First..
second...
third...
Master...
First...
second..
second..
second..
third...
third..
so on...
In the above file total..i have three blocks starting with Master & ending with third which is considered as one block.
If i split this into two files:
My first file should have:
Master.....
First...
second....
second...
third..
third...
Master...
First..
second...
third...
And my second file should have:
Master...
First...
second..
second..
second..
third...
third..
I have written the below code which is providing me one block in each file but i want to write mulitiple blocks in each file.
awk '/^1/{f=1} f{ print $0 > "file_"n ; c++} c>10000 && /^3/ { n++; c=1; close("file_"n) }' c=1 n=1 testfile
Can you please provide any suggestion to me on how to achieve this?
Thanks,
SS