在Makefile中使用$ 1 in regexp

时间:2016-07-28 07:36:13

标签: regex perl makefile

我尝试使用以下perl命令进行替换:

perl -C -p -i -e 's/([\?\.\!])\n/$1 /g' html/數14.html

当我从命令行调用它时,结果很好。当我从Makefile中调用它时,它不起作用。显然$ 1被解释为shell变量。

在Makefile中,它看起来像这样:

數14.html: 數14.adoc 40_2064_Im\ Strand-Appartment.adoc 41_2064_Ein\ Plan.adoc  42_1915_In\ einer\ Suppenküche.adoc 
    asciidoctor -D html parts/數14.adoc  
    perl -C -p -i -e 's/([\?\.\!])\n/$1 /g' html/數14.html

我怎样才能在这里有正常的正则表达式行为?

1 个答案:

答案 0 :(得分:3)

在执行命令之前,Makefile始终会解释$个序列,而忽略任何引用。要在Makefile中转义$,请将其写为$$ - 这将在命令中生成一个$