Reputation: 95
I have a question can someone advise or give some example of bash script how to fill data from file1 to file2. Below is data which needs to be transfered to file2.
FILE1 information
// -- ALL LINES BELOW WERE GENERATED --
// -- Some custom text that can be anywhere --
zone "domain40.com" {
type master;
file "domain4.com";
allow-transfer {
xx.xx.xx.xx;
2203:d1d0:0:4swd::1;
common-allow-transfer;
};
};
zone "domain50.com" {
type master;
file "domain5.com";
allow-transfer {
xx.xx.xx.xx;
2203:d1d0:0:4swd::1;
common-allow-transfer;
};
};
..............
FILE2 information
zone "domain10.com" {
type master;
file "domain10.com";
allow-transfer {
xx.xx.xx.xx;
2203:d1d0:0:4swd::1;
common-allow-transfer;
};
};
zone "domain12.com" {
type master;
file "domain12.com";
allow-transfer {
xx.xx.xx.xx;
2203:d1d0:0:4swd::1;
common-allow-transfer;
};
};
zone "domain13.com" {
type master;
file "domain13.com";
allow-transfer {
xx.xx.xx.xx;
2203:d1d0:0:4swd::1;
common-allow-transfer;
};
};
..............
So question is how can file be merged in linux with adding data from FILE1 to FILE2 only from zone to }; without any other text like // -- ALL LINES BELOW WERE GENERATED --.
I need to add that data to existing file FILE2 from imported FILE1. Any help?
Upvotes: 1
Views: 84
Reputation: 26495
If the auto-generated text begins with "/" then you could remove those lines using e.g.
grep -v "/" file1 >> file2
Would that solve your problem?
Upvotes: 1