I have a folder with multiple .sql files, each creating their own database. I'm trying the below bash script to loop through each file and initialize the database with sqlite3.
for filepath in $(find ~/sql/ -name '*.sql'); do
sqlite3 "${file}.db" -init "$filepath"
done
My issue is I have to manually type .quit in the terminal to exit sqlite3 before the bash loop continues.
I tried adding .quit but the terminal doesn't recognize the sqlite command. Do I need to add an exit command in the .sql files to exit sqlite from bash's terminal or something else?
EDIT: from the comments, I got the script to run automatically with sqlite3 "${file}.db" < "$filepath".
-batchsqlite3 -batch "${file}.db" -init "$filepath"and it's still needing manual.quit. Is that right? I also tried adding.quitto each.sqlfile and got the same issue.-init?sqlite3 "${file}.db" < "$filepath"?