How to do it...

  1. MySQL queries in script: We are going to write a script called mysql_version.sh to get the latest version of MySQL:
#!/bin/bashmysql -u root -pTraining2@^ <<MY_QUERYSELECT VERSION();MY_QUERY

Now, we are going to create a script called create_database.sh to create the database:

#!/bin/bashmysql -u root -pTraining2@^ <<MY_QUERYcreate database testdb;MY_QUERY
  1. SQLite queries in script: Now, we are going to create a sqlite database. You can create the sqlite database by simply writing sqlite3 and a name for the database. For example:
$ sqlite3 testdb

Now, we are going to create a table in the sqlite console. Enter sqlite3 testdb and press Enteryou will see the sqlite3 console. Now, write the create table command to create ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.