我在嘗試使用 aws cli 命令aws eks describe-cluster運行 for 回圈時遇到問題。我在執行時收到以下錯誤。我的腳本不是最好的。任何幫助將不勝感激。謝謝。
for i in $(aws eks list-clusters | grep dev-shark); do aws eks describe-cluster --name $i | jq '.cluster.tags."Dev-Ver"'; done
An error occurred (InvalidParameterException) when calling the DescribeCluster operation: The name parameter contains invalid characters. It should begin with letter or digit and can have any of the following characters: the set of Unicode letters, digits, hyphens and underscores.
如果我只是運行aws eks list-clusters | grep dev-shark它輸出以下內容:
aws eks list-clusters | grep dev-shark
"dev-shark-01-eks-cluster",
"dev-shark-02-eks-cluster",
"dev-shark-03-eks-cluster"
似乎是逗號 (,) 導致了錯誤?如何最好地洗掉每行末尾的 , ?
uj5u.com熱心網友回復:
引起錯誤的是逗號 (,) 和引號 (")。而不是做
aws eks list-clusters | grep dev-shark
, 你可以做
aws eks list-clusters --query 'clusters' --output text | tr '\t' '\n' | grep dev-shark
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/452808.html
