title: AWS S3 CLI ls list directories without prefix into an array (and where clause)
body: <p>From EC2 console terminal, I am trying to list a part of an S3 bucket directory names into an array excluding a prefix "date=" but cannot figure out a complete solution. </p>
  
  <p>I've already tried the following code and getting close:</p>
  
  <pre><code>origin="bucket/path/to/my/directory/" 
  for path in $(aws s3 ls $origin --profile crossaccount --recursive | awk '{print $4}'); 
  do echo "$path"; done 
  </code></pre>
  
  <p><strong>note</strong>: directory contains multiple directories like /date=YYYYMMDD/ and all I want to be returned into an array is the YYYYMMDD where YYYYMMDD is >= a certain value.</p>
  
  <p>I expect the output to be an array:</p>
  
  <pre><code>YYYYMMDD, YYYYMMDD, YYYYMMDD
  </code></pre>
  
  <p>actual result is:</p>
  
  <pre><code>path/to/my/directory/date=YYYYMMDD/file#1
  path/to/my/directory/date=YYYYMMDD/file#2
  path/to/my/directory/date=YYYYMMDD/file#3
  </code></pre>
  
  <p><a href="https://docs.aws.amazon.com/cli/latest/reference/s3/ls.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/cli/latest/reference/s3/ls.html</a></p>