1

I am trying to execute Bigquery command line through my shell script. For eg :

#!/bin/bash
bq mk -t 'projectid':'datasetid'.'TEMP_table1'

Above script works fine. But my requirement is to pass table name randomly that I need to create. so, I execute below commands in my shell script :

#!/bin/bash
Tablename=$1

echo $Tablename
bq mk -t 'projectid':'datasetid'."$(Tablename)"

When I run it as ./test.sh 'Temp_table' command fails with error :

./test.sh: line 13: Tablename: command not found BigQuery error in mk operation: Cannot determine table described by financelcr:datasetid

1 Answer 1

1

What you are attempting to do by $(..) is command-substitution to run commands within a sub-shell. What you need is variable expansion of syntax ${..}. Change your command use the argument directly

[ $# -eq 0 ] && { printf "Arguments not supplied\n"; exit 1; }
bq mk -t 'projectid':'datasetid'."${1}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.