在makefile中用SED替换行的结尾

时间:2010-04-26 13:22:47

标签: ubuntu sed append

如何通过makefile控制的SED追加到行尾?

我跑

paste -d" " t.tex tE.tex | sed 's@$@XXX@' > tM.tex

问题在于使用标记$作为行尾。

我得到了

#paste -d" " t.tex tE.tex | sed -e s/" "/\\\&/g | sed -r "s/XXX/" > tM.tex
sed: -e expression #1, char 10: unterminated `s' command
make: *** [all] Error 1

我的makefile中的“all:”标记之后只有两行,只有两行。

参数-n-e在这里没有帮助。 当命令直接在终端中运行时,该命令按预期运行。

2 个答案:

答案 0 :(得分:4)

$字符是Makefile中的特殊字符。要在命令中获取文字$,您需要通过在其前面加上另一个来引用它:$$。有关更多信息,请参阅GNU make手册中的6.1 Basics of Variable References

答案 1 :(得分:0)

你错过了最后一个sed命令中的最后一个“/”。

  paste -d" " t.tex tE.tex | sed s/" "/\\\&/g | sed -r "s/XXX//" > tM.tex

这对我在Linux上运行正常,但是这不包含你的问题提到的$ char

相关问题