外壳包括空格和星号

时间:2017-03-31 03:16:12

标签: shell space

在下面的shell脚本中定义字符串数组。我想显示sql nomal,我该怎么办?

a=("select * from t1;"
"select * from t2;"
"select  from t3;")

echo ${#a[@]}"--------"

for var1 in ${a[@]};do
    echo  "${var1}"
done

1 个答案:

答案 0 :(得分:0)

这会为你做到

a=( 'select * from t1;'
    'select * from t2;'
    'select * from t3;' )


for query in "${a[@]}"; do
  echo "$query"
done

RESULT

$ sh SO.sh 
select * from t1;
select * from t2;
select * from t3;
$