title: How to I loop through AWS CLI output?
body: <p>I am trying to pass a list of values from a aws cli query to another command.
  Even though I have seen plenty of examples in AWS, when I try all the values come together:</p>
  <pre class="lang-sh prettyprint-override"><code>  policy_versions=`aws iam list-policy-versions --query &quot;Versions[].VersionId&quot; --policy-arn $POLICY_ARN --output text`
    echo &quot;policy_versions=$policy_versions&quot;
    for ver in $policy_versions; do
      echo &quot;first version: $ver&quot;
    done
  </code></pre>
  <p>Which then prints out:</p>
  <pre><code>policy_versions=v3  v2  v1
  first version: v3   v2  v1
  </code></pre>
  <p>My value of <code>ver</code> is the entire string, it should be <code>v3</code> then <code>v2</code> and <code>v1</code>. But It is instead:
  <code>v3    v2  v1</code>.</p>
  <p>I cannot figure out what is wrong.</p>