From bash, I want to pass to sqlite3 my TSV table from stdin while also passing the name of the table to import into from a variable. How can this be accomplished? For example:
#!/bin/bash
output_sql_db="$1"
input_tsv="$2"
table_name="$3
tail -n +2 "$input_tsv" | sqlite3 "$output_sql_db" '.import "/dev/stdin" ${table_name}'
Of course in this example, ${table_name} does not get expanded correctly due to the use of ' in the sqlite3 command. How should this be done? It seems all the answers I find only show to hand handle one or the other (data import OR passing table name).