如何在 Linux 文件中的特定模式后添加值

发布于 2025-01-18 07:21:00 字数 434 浏览 1 评论 0原文

我运行一个脚本,该脚本将值存储在如下变量中:

secret=`aws secretsmanager get-secret-value --secret-id <secretid> --region eu-west-1|grep SecretString|awk -F\" '{print $4}'`

现在我有一个名为 env-list 的文件,其中包含如下条目:

secret=

我想将第一个命令的输出重定向到在 < 之后粘贴code>= 登录 env-list 文件,以便我的 env-file 保存第一个命令中的秘密值:secret=value.

我对此很挣扎。

I run a script which stores a value in a variable like this:

secret=`aws secretsmanager get-secret-value --secret-id <secretid> --region eu-west-1|grep SecretString|awk -F\" '{print $4}'`

Now I have a file called env-list which has an entry like this:

secret=

I want to redirect the output of first command to paste after = sign in env-list file, so that my env-file holds the secret value from first command: secret=value.

I am struggling a lot with this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生路 2025-01-25 07:21:00
sed -i "s/^secret=.*/secret=$secret/g" env-list
sed -i "s/^secret=.*/secret=$secret/g" env-list
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文