gpt4 book ai didi

linux - 当位置存储在变量中时,为什么 bash 找不到文件?

转载 作者:太空宇宙 更新时间:2023-11-04 10:28:07 27 4
gpt4 key购买 nike

如果 postgres 用户的主目录中不存在 .pgpass 文件,我将尝试写入该文件。

目前我有

local PASS="~postgres/.pgpass"
echo "*:*:*:*:$PWD" >> $PASS

它失败了 ~postgres/.pgpass: No such file or directory

但是,不使用变量是可行的。

echo "*:*:*:*:$PWD" >> ~postgres/.pgpass

两者有什么区别?如何将文件存储在变量中并让它工作?

最佳答案

local PASS=~postgres/.pgpass
echo "*:*:*:*:$PWD" >> "$PASS"

关于linux - 当位置存储在变量中时,为什么 bash 找不到文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40920914/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com