【发布时间】:2020-02-25 12:58:20
【问题描述】:
我在 postgres-config.ini 文件中有这些参数:
PGUSER=usr
PGPASSWORD=pass
PGDATABASE=myDB
PGHOST=localhost
PGPORT=5432
我想解析它并使用 shell 脚本(sh 文件)连接到数据库。我像这样使用 source 和 grep 命令:
source <( grep = postgres-config.ini )
但是,当我尝试使用 echo $PGHOST 打印值时,它没有打印任何内容。
谁能帮我解决我做错了什么?
【问题讨论】:
-
stackoverflow.com/questions/19331497/… 这能回答你的问题吗?
-
不,还是一样的问题(没有打印)
-
您是否从上面的问答中尝试过这个想法:
set -o allexport; source conf-file; set +o allexport
标签: postgresql shell grep sh