I have a command that works fine and looks like this:
bq query --use_legacy_sql=false --format json --batch=true 'select * from `ga4-extract.analytics_123456789.events_20220722` limit 1;' > data.json
I would like to make this part of the command 20220722
a variable.
export rundate="20220722"
Tried just:
bq query --use_legacy_sql=false --format json --batch=true 'select * from `ga4-extract.analytics_123456789.events_$rundate` limit 1;' > data.json
This ran the command without variable substitution.
I read this similar post but it looks like it's more about manipulating a string rather than an entire command. Nevertheless, from that post I tried swapping single for double quotes:
bq query --use_legacy_sql=false --format json --batch=true "select * from `ga4-extract.analytics_123456789.events_$rundate` limit 1;" > data.json
bash: ga4-extract.analytics_302644320.events_20220722: command not found
Is it possible to swap out a variable within a command, as opposed to within a string? What's the 'right' way to do what I'm trying to achieve?