title: how can i insert data from a text file into a database using shell
body: <p>i have a scenario where i have a database table that has 3 columns instance name and version which has to contain data of jenkins instance and the plugins installed along with version...and i have a text file that has the details of name and version and the code that i have to insert the name and version is </p>
  
  <pre><code>input_file="test.txt"
  cat $input_file | while read plugin version; do
          echo "INSERT INTO table_name (version,pluginname)  VALUES('$version' ,'$pluginname');"
  done | mysql -user_root -db_password dbname;
  </code></pre>
  
  <p>Now i am stuck here how can i insert the instance value in the database.
  the text file contains data for all instances, i.e the plugin name and version which i got by parsing the JSON API</p>
  
  <pre><code>curl -u user:&lt;api-token&gt; -s -k "https://&lt;jenkins instance&gt;/pluginManager/api/json?depth=1" | jq '.plugins[]|{version,longName}' -c  | sed 's/\"//g' | sed 's/,/:/g' | cut -d ":" -f2,4 &gt; test.txt
  </code></pre>
  
  <p>since the data for plugin name and version is picked up by the text file i can do that but i am not sure how to add data in the instance column.there are 6 instances to be added in total.
  A sample of that database table would be</p>
  
  <pre><code>instance     plugin  version
  instance1    plugin1  ver 1
  instance1    plugin2  ver2
  .....
  instance2    plugin1  ver1
  instance2    plugin2  ver2
  ......
  ......
  instance3    plugin1   ver1
  instance3    plugin2   ver2
  .....
  </code></pre>
  
  <p>this has to be done for all 6 instances</p>
  
  <p>how can i do this.
  Thanks in advance for answering</p>