【发布时间】:2022-02-08 01:18:48
【问题描述】:
我有一个这样的 json 文件:
{"my_string": "apple", "my_int": 456}
还有一个像这样可以正常工作的 Bash 程序:
my_program --message='{"my_string": "apple", "my_int": 456}'
但是当我的 JSON 是一个文件时,我似乎无法让它正常运行:
my_program --message=$(cat test_message.json)
我一直在寻找类似的问题,并尝试了很多东西,例如 tr、awk 以及 echo 和 cat 的各种组合,但无济于事。
这是我收到的错误,让我相信这是我在 Bash 中做错的事情:
ERROR: (gcloud.beta.pubsub.schemas.validate-message) unrecognized arguments:
"apple",
"my_int":
456}
To search the help text of gcloud commands, run:
gcloud help -- SEARCH_TERMS
如果您看到它看起来像是分解了 JSON,只取第一个空格之前的字符。有任何想法吗?我有一种感觉,这是非常基本的,但我似乎无法弄清楚。提前谢谢你。
【问题讨论】:
标签: bash gcloud google-cloud-pubsub command-substitution