简体   繁体   中英

Linux - Store a sql select value in a variable bash

I want to store the value of the sqlite statement in a variable

backup=$(sqlite3 "/home/miguel/Desktop/SO/ProjetoFinal/Backup_Principal.db" "SELECT periocidade_backup FROM STORAGE WHERE path'$path';")

But when i echo $backup it returns the following:

sqlite3 "/home/miguel/Desktop/SO/ProjetoFinal/Backup_Principal.db" "SELECT periocidade_backup FROM STORAGE WHERE path='$path';"

What am I doing wrong?

the part of your code '$path' is using a single quote which is literal and show exactly as what is in the quotes, which would not use the variable's value. using speech marks like the following should work, "'$path'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM