# My vars index=test type=book I'm trying to pass these variables to awk
awk -v index="$index" -v type="$type" 'BEGIN{print "{\"create\": {\"_index\":\"index\", \"_type\":\"type\"}}"}; {print}; END {printf "\n"}' Desired output
{"create": {"_index":"test", "_type":"book"}}