Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write Dollar sign in sed command pattern inside makefile

I have a makefile that contains this command:

sed '/^$/d'

when I ran it I got:

sed '/^d'
sed: -e expression #1, char 3: unterminated address regex

looks like it interprets the dollar sign, how can I prevent that from happening?

like image 953
Shadi Avatar asked Jul 14 '26 00:07

Shadi


1 Answers

You have to double all dollar signs in a recipe, otherwise make treats them as introducing a make variable:

sed '/^$$/d'

If you search for "dollar sign makefile" or similar you'll find tens if not hundreds of answers to virtually this exact question.

like image 54
MadScientist Avatar answered Jul 15 '26 15:07

MadScientist