Reputation: 43
I'm trying to run the following lines of code in bash to run multiple files on a database.
#!/bin/bash
for file in ${arrIN}; do
echo "Executing ${file}..";
sqlplus ${db_user}/${db_password}@${db_host}:1521/${db_sid} @${file};
done
For some reason, it will only execute the first file on the database, but won't keep executing them. When I check how many files are in arrIn it prints two, so I know there are multiple files. When I run this:
file1=${arrIN[0]}
file2=${arrIN[1]}
sqlplus ${db_user}/${db_password}@${db_host}:1521/${db_sid} @${file1}
sqlplus ${db_user}/${db_password}@${db_host}:1521/${db_sid} @${file2}
It executes both files as expected. I would like to acomplish this in a for loop
Upvotes: 0
Views: 265
Reputation: 8611
#!/bin/bash
arr=("0000" "1111")
for i in "${arr[@]}"
do
echo $i
done
[@]
to loop on all the items in the array.[@]
, it just loops on the first item, like you experienced.Upvotes: 1