Regex 如何用Makefile中的其他文件内容替换字符串

Regex 如何用Makefile中的其他文件内容替换字符串,regex,shell,makefile,Regex,Shell,Makefile,我有一个包含一些include行的文件,我想读取文件路径并用文件内容替换这一行 e、 g.将行替换为path/filename.txt # meta info - a - b # included files <!-- include(path/filename.txt) --> #元信息 -a -b #包括的文件 我的生成文件: expand-includes: @echo "Expand all included file" perl -pi -e "s/&

我有一个包含一些
include
行的文件,我想读取文件路径并用文件内容替换这一行

e、 g.将行
替换为
path/filename.txt

# meta info
- a
- b

# included files
<!-- include(path/filename.txt) -->
#元信息
-a
-b
#包括的文件
我的生成文件:

expand-includes:
    @echo "Expand all included file"
    perl -pi -e "s/<!--\s?include\((.+)\)\s?-->/`cat $$1`/" input.txt
expand包括:
@echo“展开所有包含的文件”
perl-pi-e“s/`cat$$1`/”input.txt
捕获组看起来为空
$$1
,脚本挂起。 我错过什么了吗

更新:
Remove$(shell)

以下语法运行良好


perl-p-e's/`cat$$1`/e'input.txt>output.txt

首先,配方是由shell运行的,那么为什么需要
$(shell…
?其次,
$1
是空的,因为shell将其展开,因为它位于双引号字符串中(替换第一个位置参数的值,该参数为空)。另外,如果我记得关于Perl的任何内容(请注意,我不一定记得),您希望使用
\1
来引用“匹配寄存器#1”-
cat$$1
将替换名为
$1
的文件的内容(重复一下,这是一个空字符串),不确定是什么意思。为什么要使用
cat$$1
,而在Perl中使用
-i
选项修改?谢谢@MichaelLivshin和@k-five。我想用相应的文件内容替换字符串,因此需要
-I
选项。我试了一会儿,发现e修饰符正是我所需要的
perl-pi-e's/`cat$$1`/e'input.txt