title: How to assign a string column to variable and have it quoted in output in Bash script
body: <p>In this <a href="https://stackoverflow.com/questions/66716484/how-to-auto-quote-string-values-of-a-sql-insert-statement-in-bash-script">post</a>, I had asked a question as to how I can have my script read a CSV header and <em>auto-quote</em> string values; i.e. automatically wrap those columns whose data type is string and would need &quot;&quot; in order to be inserted into a SQL table. Apparently, this would be more than what Bash can handle?</p>
  <p>At any rate, I'd welcome any help regarding how I can make the following script work: here, I have basically the same script but I <em>tried</em> to manually define separate columns and assign them to variables with col3 being a string column, hence quoted. Needless to say, it doesn't do what I want it to do (i.e. give me quoted values for all the string data under col3). Thanks!</p>
  <pre><code>#!/bin/bash
  
  echo Path to to-be-imported CSV:
  read csv_file
  echo Table name to import into:
  read table
  
  echo &quot;INSERT INTO $table VALUES&quot; &gt; SQL_INSERT_$table.txt
  while read col1 col2 col3 col4
  do
   echo &quot;($col1 $col2 &quot;$col3&quot; $col4),&quot;
  done &lt; &lt;(tail -n +2 $csv_file) &gt;&gt; SQL_INSERT_$table.txt &amp;&amp; sed -i '' '$ s/.$/;/' SQL_INSERT_$table.txt
  </code></pre>