This is the code I have
# filename: script.sh
cluster="some_cluster_name"
aws_cli_response=$(aws ecs list-services --cluster $cluster_name --output text)
echo $aws_cli_response
echo "${aws_cli_response}"
The resulting output of sh script.sh
is
SERVICEARNS <arn1> SERVICEARNS <arn2> SERVICEARNS <arn3> ...
SERVICEARNS <arn1>
SERVICEARNS <arn2>
SERVICEARNS <arn3>
...
I didn't expect "${aws_cli_response}"
to somehow make the one line string into a well structured line by line result. I thought it would require some sort of looping logic to create this line by line result. But I was surprised by getting this result.
So to investigate how this result could have happened I've created a simple script that looks like this:
text="SERVICEARNS text1 SERVICEARNS text2"
echo $text
echo "${text}"
But to my surprise I got this result that I would previously have anticipated had I not seen the first script's outcome:
SERVICEARNS text1 SERVICEARNS text2
SERVICEARNS text1 SERVICEARNS text2
Could anyone explain why the first that simply echos a string variable which is just a bunch of single line text result in this clean looking string result?
Thanks in advance. Happy coding everyone.