将变量从表传递到shell脚本

时间:2016-09-17 18:56:31

标签: shell while-loop

我有一张以下格式的表格。 enter image description here 现在,我试图从表中获取值并将其传递给shell脚本。

#!/bin/bash
# Connect to DB and spool query result into a CSV file
export ORACLE_HOME=/usr/oracle/current
nohup $ORACLE_HOME/bin/sqlplus -s -s user/password@TEST123 << EOF
set echo off head off feed off pagesize 0 trimspool on linesize 1000 colsep   ,
spool output.csv
select Url , TAG from ABHAY_TEST;
spool off;
exit;
EOF
# Using while loop read values into variables from CSV file and create flat   file for each records
counter=1
while IFS=, read -r V1 V2
 do
  curl -s "${V1}" | grep -Po "${V2}" | wc -l
  counter=$(( counter + 1 ))
  done < output.csv

但我无法得到理想的结果。我确信在从Table收集数据并将其作为变量传递给脚本时我会犯错。

有人可以帮我吗?

0 个答案:

没有答案
相关问题