I am saving output of my command in a variable and using it in other command
instance_id=$(aws ec2 describe-instances --query Reservations[*].Instances[*].[InstanceId] --filters "Name=tag:staging,Values=staging")
I get this output [ [ [ "i-09140824c1b7f9ea7" ] ] ]
How to I remove brackets from the output and use it in the variable in this command
aws ec2 associate-address --instance-id $instance_id --allocation-id allocid
I am new to bash so any help would be appreciated.
jq
.--output text
no?aws
to emit plaintext output would be even better."$instance_id"
in your final command. Basically, every expansion should be quoted unless you have a very explicit reason not to; see shellcheck.net warning SC2086.