I hava a Makefile which needs to extract some information from a textfile `someText.txt by using awk. Here is an example:
Executing awk on my textfile manually in the console works pretty fine:
$ cat someText.txt | awk '/Total number:/ {print $NF}'
$ 42
But using it in my makefile does not work:
MYVAR=$(shell cat someText.txt | awk '/Total number:/ {print $NF}')
all:
@echo Count: $(MYVAR)
The output is: Count:
But I would suggest the output is Count: 42
MYVAR=$(shell awk '/Total number:/ {print $$NF}' someText.txt)
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