我不想手动运行这些命令。如何在 bash 脚本中自动执行此操作?
sqlite3 /var/lib/pve-cluster/config.db
sqlite> select * from tree where name = 'corosync.conf';
sqlite> delete from tree where name = 'corosync.conf';
sqlite> select * from tree where name = 'corosync.conf';
sqlite> .quit
我使用heredocs:
sqlite3 /var/lib/pve-cluster/config.db <<EOF
select * from tree where name = 'corosync.conf';
delete from tree where name = 'corosync.conf';
select * from tree where name = 'corosync.conf';
EOF
只需执行以下操作:
sqlite3 /path/to/file.db "$command"
从命令提示符。
例如:
sqlite3 /var/lib/pve-cluster/config.db "select * from tree where name = 'corosync.conf';"