I want to execute a Shell command but I didn't know how to do a sub bash command correctly in my Makefile
import-bd:
@while ! nc -z $(make ips | awk '/mysql/ { print $2 }') 3306; do \
sleep 1 \
done
...
Thanks for your help !
You need to quote the $
s and add a ;
import-bd:
@while ! nc -z $$(make ips | awk '/mysql/ { print $$2 }') 3306; do \
sleep 1; \
done
When make sees a single $
, it tries to do a variable expansion. By writing $$
, make passes a single $
to awk (or, more precisely, it passes a single $
to SHELL which invokes awk
). Also, the semi-colon after sleep 1
is needed because make strips the newline.
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