dir-compare 465 B

123456789101112131415
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. IFS=$'\n\t'
  4. # Compare two directories, listing files that exist only in the first and not
  5. # the second.
  6. #
  7. # Useful for quickly comparing two directories for missing files. From
  8. # https://stackoverflow.com/questions/28205735/how-do-i-compare-file-names-in-two-directories-in-shell-script
  9. [[ $# != 2 ]] && echo "Usage: ${0##*/} dir1 dir2" && exit 1
  10. dir1=$1
  11. dir2=$2
  12. find "$dir2" "$dir2" "$dir1" -printf '%P\n' | sort | uniq -u