我编写了一个 shell 脚本来使用 jq 读取 json 文件并编写该文件的漂亮版本:
cat input.json | jq . > pretty.json
cp pretty.json ./input.json
rm pretty.json
Run Code Online (Sandbox Code Playgroud)
需要第 2 行和第 3 行是因为
cat input.json | jq . > input.json
Run Code Online (Sandbox Code Playgroud)
将文件留空,有没有办法使用 shell/jq 来美化文件而不使用临时文件?