How to do it...

  1. Open a terminal, and create the file-deduplicator.sh script.

The following is a code snippet of the script:

#!/bin/bashdeclare -a FILE_ARRAY=()function add_file() {  # echo $2 $1  local NUM_OR_ELEMENTS=${#FILE_ARRAY[@]}  FILE_ARRAY[$NUM_OR_ELEMENTS+1]=$1}function del_file() {  rm "$1" 2>/dev/null}
  1. Run the setup command if not already: run $ bash dsetmkr.sh and then run $ bash ./file-deduplicator.sh. Enter files_galore/ at the prompt and press Enter:
$ bash dsetmkr.sh $ bash file-deduplicator.shEnter directory name to being searching and deduplicating:Press [ENTER] when readyfiles_galore/#1 f559f33eee087ea5ac75b2639332e97512f305fc646cf422675927d4147500d4c4aa573bd3585bb866799d08c373c0427ece87b60a5c42dbee9c011640e04d75#2 f7559990a03f2479bf49c85cb215daf60417cb59875b875a8a517c069716eb9417dfdb907e50c0fd5bd47127105b7df9e68a0c45a907dc5254ce6bc64d7ec82a ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.