wellster34
Programmer
Hi,
I have a data file like the following:
BEGIN 1ST FILE|
1|2|3|4|5
6|7|8|9|10
END 1ST FILE|
BEGIN 2ND FILE|
A|B|C|D|E
F|G|H|I|J
END 2ND FILE|
BEGIN 3RD FILE|
.....ETC....
Is there a way to extract the data just for the 1ST File and then 2ND File and etc...?
I need to ouput the 1ST FILE to a file called 1.dat
Then the 2ND FILE to the file called 2.dat and the 3RD FILE to 3.dat and so on.
I understand I might have to run the same command but different criteria. I tried the following but it did not work:
sed '/BEGIN 1ST FILE/d;/END 1ST FILE/q' main.dat > 1.dat
sed '/BEGIN 2ND FILE/d;/END 2ND FILE/q' main.dat > 2.dat
The 1.dat works!!! Yeah! But when the 2.dat was created, it contains all the data from the 1.dat too... :-(
I was curious if anyone had any ideas on how to resolve this? Any help is greatly appreciated!
Thanks for your time.
I have a data file like the following:
BEGIN 1ST FILE|
1|2|3|4|5
6|7|8|9|10
END 1ST FILE|
BEGIN 2ND FILE|
A|B|C|D|E
F|G|H|I|J
END 2ND FILE|
BEGIN 3RD FILE|
.....ETC....
Is there a way to extract the data just for the 1ST File and then 2ND File and etc...?
I need to ouput the 1ST FILE to a file called 1.dat
Then the 2ND FILE to the file called 2.dat and the 3RD FILE to 3.dat and so on.
I understand I might have to run the same command but different criteria. I tried the following but it did not work:
sed '/BEGIN 1ST FILE/d;/END 1ST FILE/q' main.dat > 1.dat
sed '/BEGIN 2ND FILE/d;/END 2ND FILE/q' main.dat > 2.dat
The 1.dat works!!! Yeah! But when the 2.dat was created, it contains all the data from the 1.dat too... :-(
I was curious if anyone had any ideas on how to resolve this? Any help is greatly appreciated!
Thanks for your time.