bash - pass values from a file as a Makefile variable -
i use values file pass command in make. problem context passing set of ids fetch proteins ncbi using eutils cli. thought of using process substitution pass file location , need string. trying set local bash variable , use in make step cannot work. hints appreciated.
zachcp
shell := /bin/bash # efetch 1 id test1.txt: efetch -db protein -id 808080249 -format xml >$@ # efetch two, comma-separated ids test2.txt: efetch -db protein -id 808080249,806949321 -format xml > $@ # put ids in file.... data.txt: echo "808080249\n806949321" > $@ # try call ids process substitution. # doesn't expand before being called trips error... test3.txt: data.txt efetch -db protein -id <(cat $< | xargs printf "%s,") -format xml > $@ # try set , use local bash variable test4.txt: data.txt ids=`cat $< | xargs printf "%s,"` efetch -db protein -id $$ids -format xml > $@
text3.txt work if use $(...) or `...` instead of <(...)
test3.txt: data.txt efetch -db protein -id $$(cat $< | xargs printf "%s,") -format xml > $@
text4.txt fails because each line executed in different shell process, variable set in first line out of scope in second one; work if put both statements on same line:
test4.txt: data.txt ids=`cat $< | xargs printf "%s,"`; efetch -db protein -id $$ids -format xml > $@
Comments
Post a Comment