how to read a yaml file and update itself ?

let’s said I have a yaml file like

centers.yml

centers:

  • center_id: ABC123
    center_password: 123456789
  • center_id: 123ABC
    center_password: “”

now I want to read the centers.yml , and update center_password with pwgen(8) if center_password is null and write back to centers.yml

How should I do the job ?

Is this file local or on your remote host?

Is this file local or on your remote host?

local

dick....@geant.org 在 2021年11月5日 星期五下午3:04:57 [UTC+8] 的信中寫道:

This should work, although it could probably be optimised:

WOW , that’s incredible ! thanks !

dick....@geant.org 在 2021年11月8日 星期一下午6:04:56 [UTC+8] 的信中寫道: