How to use commands in makefile shell command?

I have the following code snippet in a Makefile that always fails if I do not remove the links to sed and grep below.

TAB=$(shell printf "\t") all: abstract.tsv $(shell cut -d "${TAB}" -f 3 abstract.tsv | sed "s/^\s*//" | \ sed "s/\s*$//" | grep -v "^\s*$" | sort -f -S 300M | \ uniq > referenced_images.sorted.tsv) 

This is the error I get:

 /bin/bash: -c: line 0: unexpected EOF while looking for matching `"' /bin/bash: -c: line 1: syntax error: unexpected end of file 

What could be wrong?

+6
source share
1 answer

One error comes from sed . When you write:

 sed "s/\s*$//" 

make extends the $/ variable to an empty string, so sed does not have a separator. Try:

 sed "s/\s*$$//" 

Using $" causes the same problem in grep . Instead, use grep -v "^\s*$$" .

+17
source

All Articles