title: Delete all files older than 30 days, based on file name as date
body: <p>I'm new to bash, I have a task to delete all files older than 30 days, I can figure this out based on the files name <code>Y_M_D.ext</code> <code>2019_04_30.txt</code>.</p>
  
  <p>I know I can list all files with <code>ls</code> in a the folder containing the files. I know I can get todays date with <code>$ date</code> and can configure that to match the file format <code>$ date "+%Y_%m_%d"</code> </p>
  
  <p>I know I can delete files using <code>rm</code>.</p>
  
  <p>How do I tie all this together into a bash script that deletes files older than 30 days from today?</p>
  
  <p>In pseudo-python code I guess it would look like:</p>
  
  <pre><code>for file in folder:
      if file.name to date &gt; 30 day from now:
          delete file
  </code></pre>