简体   繁体   中英

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. The startup script downloads a file config.toml then edits the file config.toml via sed . When I check the startup script logs via

cat /var/log/syslog

sed: can't read: No such file or directory

My startup script for 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:

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?

You can use sed command in many ways...

Below are examples to replace 'abc' with 'def'

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM