简体   繁体   English

GCP VM启动脚本sed:无法读取:没有这样的文件或目录

[英]GCP VM startup script sed: can't read : No such file or directory

I have a terraform GCP VM instance (Ubuntu 18.04 LTS Minimal) metadata startup script which is defined via inline.我有一个通过内联定义的 terraform GCP VM 实例(Ubuntu 18.04 LTS Minimal)元数据启动脚本。 The startup script downloads a file config.toml then edits the file config.toml via sed .启动脚本下载文件config.toml然后通过sed编辑文件config.toml When I check the startup script logs via当我通过检查启动脚本日志时

cat /var/log/syslog

sed: can't read: No such file or directory sed:无法读取:没有这样的文件或目录

My startup script for sed :我的sed启动脚本:

chmod -R 777 /pd-disk/config.toml
sed -i 's/http:\/\/localhost:8545/http:\/\/bor:8545/g' /pd-disk/config.toml

I know the command works properly if I SSH into the VM and manually execute the sed command:如果我 SSH 进入 VM 并手动执行sed命令,我知道该命令可以正常工作:

sed -i 's/http://localhost:8545/http://bor:8545/g' /pd-disk/config.toml

What is the proper method or syntax for sed to execute within the startup script? sed 在启动脚本中执行的正确方法或语法是什么?

You can use sed command in many ways...您可以通过多种方式使用 sed 命令...

Below are examples to replace 'abc' with 'def'下面是用 'def' 替换 'abc' 的示例

  • sed -i 's|abc|def|g' tmp.txt sed -i 's|abc|def|g' tmp.txt
  • sed -i 's@abc@def@g' tmp.txt sed -i 's@abc@def@g' tmp.txt
  • sed -i 's.abc!def!g' tmp.txt sed -i 's.abc!def!g' tmp.txt

In this way, you can use any delimiter as separator.这样,您可以使用任何分隔符作为分隔符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GCP linux 启动脚本授予所有用户对目录和文件的权限 - GCP linux startup script to grant all users permission to directory and files 新 VM 不能使用未分配的 Static 内部 IP GCP - New VM can't use unassigned Static Internal IP GCP 无法连接到 GCP centos7 vm 中的 Jfrog 工件实例 - Can't connect to Jfrog artifactory instance in GCP centos7 vm 无法连接到 GCP VM 权限被拒绝(公钥)错误 - Can't connect to GCP VM Permission denied (publickey) error GCP 将文件从我的本地机器复制到 GCP Vm - GCP Copying File from my local Machine to GCP Vm 使用 JAVA 从 GCP VM 获取属性文件内容 - Fetch a property file content from GCP VM using JAVA 检查 GCP 上的虚拟机是否连接到 GCP VPN 网关 - Check that VM on GCP is connecting to GCP VPN Gateway 如何防止我的 GCP VM 实例中的用户成为 root? - How can prevent users in my GCP VM Instance to become root? 您可以在我的 GCP VM 上使用 Jupyter notebook 在 Google Cloud 中运行 TPU 训练吗? - Can you use a Jupyter notebook on my GCP VM to run TPU training in Google Cloud? 如何从 GCP Cloud Function 中的 maven 资源文件夹中读取文件? - How to read a file from maven resources folder in GCP Cloud Function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM