title: Choose folder from tree of folders in s3 using Bash script
body: <p>I have files which existing under s3 path like below:
  s3://ttttt/2018/11/01/02 -->(tttt=s3 bucket, 2018=year, 11=moth, 01=day, hour=02)</p>
  
  <p>I have a new files all the time which inserted in s3 as the example below:</p>
  
  <pre><code>s3://tttt/2018/10/01/01/ls.s3.4cede5e7d25c.2018-10-01T01.00.tag_lre.txt.gz 
  s3://tttt/2018/10/01/01/ls.s3.4cede5e7d25c.2018-10-01T01.00.tag_lre.txt.gz
  s3://tttt/2018/10/01/02/ls.s3.4cede5e7d25c.2018-10-01T02.00.tag_lre.txt.gz
  </code></pre>
  
  <p>I would like to pick up via Bash script:
  1. max year
  2. max month
  3. max day
  4. max hour</p>
  
  <p>The script that I built seems like that (but does not work good):</p>
  
  <pre><code>#!/bin/bash
  result=`aws s3 ls "s3://tttt/2018/" | awk '{print $2}' |tail -n 1` 
  result1=`aws s3 ls "s3://tttt/2018/${result:0:2}/" | awk '{print $NF-1}' |tail -n 1` 
  result2=2018/${result:0:2}/${result1:0:2}/
  </code></pre>
  
  <p>Any ideas how to write it?</p>