Reputation: 64
I have folder which has 500 database. I want get value from them. Inside the for loop ATTACH '$i' AS db2; not work. If i write to name of folder instead of $i code is work.
How can make a db_name as a varible
#!/bin/bash
clear
for i in $( ls ); do
if [[ $i != test.sh ]]; then
if [[ $i != abc.db3 ]]; then
echo "--------- " $i " ---------"
sqlite3 abc.db3 <<'EOF'
ATTACH '$i' AS db2;
INSERT INTO Test (userId, sender, date) SELECT user_id, sender, send_date FROM db2.mt;
EOF
fi
fi
done
echo "-------- Finish ----------"
Upvotes: 0
Views: 29
Reputation: 180010
You have disabled parameter substitution by quoting the heredoc label.
Use <<EOF
instead.
Alternatively, open the database $i
directly and attach abc.db3
to it.
Upvotes: 2