title: How do I compare file names in two directories in shell script?
body: <p>Right now, this is what my code looks like:</p>
  
  <pre><code>#!/bin/bash
  
  Dir1=$1
  Dir2=$2
  
  for file1 in $Dir1/*; do
      for file2 in $Dir2/*; do
          if [[ $file1 == $file2 ]]; then
              echo "$file1 is contained in both directories"
          fi
      done
  done
  </code></pre>
  
  <p>I am trying to compare the file names of the two directories entered and say that the file is in both directories if the filename matches.
  When I try to run it though, nothing is echo-ed even though I have the same file in both directories.</p>