I want to get memorydb endpoint URL in the format (address:port). When I run the aws cli command aws memorydb describe-clusters --cluster-name xxx --query 'Clusters[0].ClusterEndpoint' --output text
, I get the output as (address port).
I want to get it in the format (address:port). Is there a command i can use to add ':' to combine address and port number.
Thanks
CodePudding user response:
Possible to achieve this by using simple sed
, something like this:
aws memorydb describe-clusters --cluster-name xxx --query 'Clusters[0].ClusterEndpoint' --output text | sed 's/ /:/g'
See if this works! I haven't tested it with aws cli.
CodePudding user response:
Assuming you have set your variable to the string which you posted, i.e.
x='(address port)'
you can calculate
y=${x/ /:}
which gives you on y
the value (address:port)
.