Consider a directory containing (only) the 3 files obtained by:
echo "foobar" > test1.txt
echo "\$foobar" > test2.txt
echo "\$\$foobar" > test3.txt
(and thus containing respectively foobar
, $foobar
, $$foobar
).
The grep
instruction:
grep -l -r --include "*.txt" "\\$\\$" .
filters the files (actually, the unique file) containing double dollars:
$ grep -l -r --include "*.txt" "\\$\\$" .
./test3.txt
So far, so good. Now, this instruction fails within a makefile, e.g.:
doubledollars:
echo "Here are files containing double dollars:";\
grep -l -r --include "*.txt" "\\$\\$" . ;\
printf "\n";\
leads to the errors:
$ make doubledollars
echo "Here are files containing double dollars:";\
grep -l -r --include "*.txt" "\\\ . ;\
printf "\n";\
/bin/sh: -c: ligne 2: unexpected EOF while looking for matching `"'
/bin/sh: -c: ligne 3: syntax error: unexpected end of file
makefile:2: recipe for target 'doubledollars' failed
make: *** [doubledollars] Error 1
Hence my question: how to escape double dollars in a makefile?
Edit: note that this question does not involve Perl.
$
in a makefile recipe by doubling it$$
. See Using Variables in Recipes. – Giannini