我正在尝试根据特定标准替换文本文件中的文本。
例如,如果我有三个文本文件,其中 outer.txt 包含:
Blah Blah Blah
INCLUDE inner1.txt
Etcetera Etcetera
INCLUDE inner2.txt
end of file
和 inner1.txt 包含:
contents of inner1
和 inner2.txt 包含:
contents of inner2
在替换结束时,outer.txt 文件如下所示:
Blah Blah Blah
contents of inner1
Etcetera Etcetera
contents of inner2
end of file
总体模式是,对于单词“INCLUDE”的每个实例,将整行替换为文件名紧跟“INCLUDE”实例之后的文件的内容,在一种情况下是 inner1.txt,在第二种情况下案例将是 inner2.txt。
更简单地说,gawk 是否有可能根据外部文本文件中要替换的内容来确定将哪个文本文件嵌入到外部文本文件中?