title: Bash script to compare files
body: <p>I have a folder with a ton of old photos with many duplicates. Sorting it by hand would take ages, so I wanted to use the opportunity to use bash. </p>
  
  <p>Right now I have the code:</p>
  
  <pre><code>#!/bin/bash
  
  directory="~/Desktop/Test/*"
  for file in ${directory};
  do
      for filex in ${directory}:
      do
          if [ $( diff {$file} {$filex} ) == 0 ]
          then
              mv ${filex} ~/Desktop
              break
          fi
      done
  done 
  </code></pre>
  
  <p>And getting the exit code:</p>
  
  <pre><code>diff: {~/Desktop/Test/*}: No such file or directory
  diff: {~/Desktop/Test/*:}: No such file or directory
  File_compare: line 8: [: ==: unary operator expected
  </code></pre>
  
  <p>I've tried modifying working code I've found online, but it always seems to spit out some error like this. I'm guessing it's a problem with the nested for loop?</p>
  
  <p>Also, why does it seem there are different ways to call variables? I've seen examples that use <code>${file}, "$file", and "${file}"</code>.</p>