tags:

views:

117

answers:

2

How can you append to the end of a line by SED controlled by makefile?

I run

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

where the problem is in the use of the mark $ for the end of the line.

I get

#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

I have the command just after the "all:" tag in my makefile which contains only the two lines.

The parameters -n and -e do not help here. The command works as expected run when it is run directly in terminal.

A: 

You are missing the final "/" from the last sed command.

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

this works fine for me on linux, however this does not contain the $ char your problem mentions

IanNorton
+3  A: 

The $ character is a special character in Makefiles. To get a literal $ in a command you need to quote it by prefixing it with another one: $$. For more information, see 6.1 Basics of Variable References in the GNU make manual.

Jukka Matilainen