这里用 yq 编辑数组中的 yaml 对象。加速 Terminalizer 的终端演员(记录)我问过如何用 yq 编辑 yaml。我收到了最好的答案。但默认情况下yq
会删除注释和空行。如何防止这种行为?
input.yml
# Specify a command to be executed
# like `/bin/bash -l`, `ls`, or any other commands
# the default is bash for Linux
# or powershell.exe for Windows
command: fish -l
# Specify the current working directory path
# the default is the current working directory path
cwd: null
# Export additional ENV variables
env:
recording: true
# Explicitly set the number of columns
# or use `auto` to take the current
# number of columns of your shell
cols: 110
执行
yq -y . input.yml
结果
command: fish -l
cwd: null
env:
recording: true
cols: 110