title: Script to remove older files from various directories
body: <p>I want to remove files(whose name contains &quot;extract&quot;) older than 7 days from various directories in a particular path.
  If I run the script without any argument the script should be able to delete the files from all the directories inside that particular path.
  If I run the script using any arguments , then the script should not delete files from those specific directories.</p>
  <p>Example :-</p>
  <p>Path - /languages/analytics</p>
  <p>Let's assume directory &quot;analytics&quot; contains 10 dirctories like c,java,javascript,python,shell,golang,scala,ruby,react,angular.This directory also contains few files along with these 10 directories.</p>
  <p>Scenario1 - I want to remove the files older than 7 days from all the 10 directories.</p>
  <p>Scenario2 - I want to remove the files older than 7 days from all directories except angular.</p>
  <p>Scenario3 - I want to remove the files older than 7 days from all directories except ruby,react,shell.</p>
  <p>So basically whatever arguments I pass , the script should not delete files from those particular directories.The number of arguments may vary as per requirement.And if I run without arguments, then the script should delete older files from all the directories in that path.The number of directories may vary as well.</p>
  <p>Here is what I have written so far ...</p>
  <pre><code>#!/bin/bash
  
  cd /languages/analytics
  for f in *; do
      if [ -d &quot;$f&quot; ] &amp;&amp; [[ &quot;$f&quot; != $1 ]]; then
          find /languages/analytics/&quot;$f&quot; -mtime +7 -name '*extract*' -exec rm -f {} \;        
      fi
  done
  </code></pre>
  <p>The above script works fine when I run it without arguments.
  It runs fine when I pass 1 argument.</p>
  <p>sh scriptname -&gt; successfully deletes files from all directories in /languages/analytics path.</p>
  <p>sh scriptname ruby -&gt; successfully delete files from all directories except ruby.</p>
  <p>Can you please advise how to enhance this script to take as many arguments as possible and the script should not delete files from those particular directories which are passed in the argument ?</p>