Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running sqlite3 script inside bash

Tags:

bash

sqlite

I am trying to run multiple commands from a bash file of sqlite3 on ubuntu 15.10. The code is to pull the passwords from the user's google chrome and email it to them. I have everything but the sqlite3 part down. I'm trying to make this as simple and as easy to use for them as possible. I don't know sqlite3 and it's kicking my tail. How would I produce a bash file using this sqlite3 code?

sqlite3 'Login Data'
.mode csv
.headers on
.separator ","
.output UsersPW.csv
select * from logins;
.exit
like image 281
David Avatar asked Jun 11 '26 18:06

David


1 Answers

The answer was simple enough. Inside batch you can echo large data with << EOF structure.

sqlite3 'Login Data' << EOF
.mode csv 
.headers on 
.separator "," 
.output UserPW.csv 
select * from logins; 
.exit
EOF

This created the results I was needing.

like image 123
David Avatar answered Jun 14 '26 12:06

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!