I have the following code snippet in a Makefile which always fails unless I remove the references to sed & 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?
In the shell, the pipe symbol causes the stdout from the command on the lefto be hooked up to the stdin of the command on the righ: it's called a pipeline or piping data.
Order-only prerequisites can be specified by placing a pipe symbol ( | ) in the prerequisites list: any prerequisites to the left of the pipe symbol are normal; any prerequisites to the right are order-only: targets : normal-prerequisites | order-only-prerequisites.
One error is coming from sed
. When you write:
sed "s/\s*$//"
make expands the variable $/
to an empty string, so sed is missing a delimiter. Try:
sed "s/\s*$$//"
Using $"
is causing the same problem in grep
. Use grep -v "^\s*$$"
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With