Makefile variable not set from grep output -
i trying set variable cogline output of grep line (which searching config.json file regexthe "cogs"). when execute grep line correctly outputs proper line number, when echo variable comes blank.
cogline = $(grep -n \"cogs\" ~/desktop/repos/pronghorn/config.json | cut -f1 -d:) all: grep -n \"cogs\" ~/desktop/repos/pronghorn/config.json | cut -f1 -d: echo $(cogline)
here output:
glennmbp:test glenn$ make grep -n \"cogs\" ~/desktop/repos/pronghorn/config.json | cut -f1 -d: 2 echo
you can see line number found "2", variable comes blank if not set. doing wrong?
grep
not make function. cogline =
line make assignment.
you either need use
cogline := $(shell grep -n \"cogs\" ~/desktop/repos/pronghorn/config.json | cut -f1 -d:)
if want run @ make parse time , want in make variable.
or
all: cogline=$$(grep -n \"cogs\" ~/desktop/repos/pronghorn/config.json | cut -f1 -d:); \ echo "$${cogline}"
to run @ all
recipe execution time , have in shell variable.
there middle grounds 2 basic ideas.
Comments
Post a Comment