首页 > 解决方案 > 在 sqlite3 中显示多行消息

问题描述

我正在尝试使用、、、和命令在 sqlite3 中显示一些多行消息,echo但我cat总是有错误。我想要的输出是这样的:readprintf

在文本文件中显示表格:
.once -e
从表 1 中选择 *;

在电子表格中显示表格:
.一次-x
从表 1 中选择 *;

我试过这个,但每个命令都会使输出混乱:

.shell echo "display the table in a text file:"
.shell echo ".once -e"
.shell echo "SELECT * from table1;"

.shell echo "display the table in a spreadsheet:"
.shell echo ".once -x"
.shell echo "SELECT * from table1;"

所以我尝试了:

.shell cat << EndOfMessage
display the table in a text file:
.once -e
SELECT * from table1;

display the table in a spreadsheet:
.once -x
SELECT * from table1;
EndOfMessage
;

和:

.shell read -r -d '' VAR << EndOfMessage

display the table in a text file:
.once -e
SELECT * from table1;

display the table in a spreadsheet:
.once -x
SELECT * from table1;

EndOfMessage
;
.shell echo "$VAR"

但两者都给出了几个错误。

标签: bashsqlitecommand-lineechomultiline

解决方案


推荐阅读