[英]Append/supplement data from file1 to file2 (linux)
I have a question can someone advise or give some example of bash script how to fill data from file1 to file2.我有一个问题,有人可以建议或举一些 bash 脚本的示例如何将数据从文件 1 填充到文件 2。 Below is data which needs to be transfered to file2.下面是需要传输到file2的数据。
FILE1 information FILE1 信息
// -- 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 FILE2 信息
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 };所以问题是如何将文件合并到 linux 中,仅将数据从 FILE1 添加到 FILE2 从 zone 到 }; without any other text like // -- ALL LINES BELOW WERE GENERATED --.没有任何其他文本,例如 // -- 下面的所有行都已生成 --。
I need to add that data to existing file FILE2 from imported FILE1.我需要将该数据从导入的 FILE1 添加到现有文件 FILE2。 Any help?有什么帮助吗?
If the auto-generated text begins with "/" then you could remove those lines using eg如果自动生成的文本以“/”开头,那么您可以使用例如删除这些行
grep -v "/" file1 >> file2
Would that solve your problem?那能解决你的问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.