Reputation: 17
It;s only outputting the final loop body because of the way my loop is set up, the variable var's final result will be the final element in my array. How would I loop through the body and add all of the results of my array to the .sql file?
Upvotes: 0
Views: 59
Reputation: 249133
Try this:
echo "CREATE TABLE $NameOfTable (" > "$NameOfSqlFile.sql"
for i in "${ColumnArray[@]}"
do
echo "$i,"
done >> "$NameOfSqlFile.sql"
echo ")" >> "$NameOfSqlFile.sql"
Upvotes: 1