File my-fdupes.sh of Package geant4-data-template

#/bin/bash

DiectoryToCheck=${1}
PatternToDelete=${2}

target=""
declare -a sources
fdupes -qnr ${DiectoryToCheck} | while read line ; do
   if [ "${line}" == "" ] ; then
      if [ ! "${target}" == "" ] || [ ! ${sources[0]} == "" ] ; then
         if [ "${target}" == "" ] ; then
            target="${sources[0]}"
            unset sources[0]
         fi
         for sourc in ${sources[@]} ; do
            rm -rf ${sourc}
            ln -s -r ${target} ${sourc}
         done
         target=""
         unset sources
      fi
   else
      if echo "${line}" | grep -v "${PatternToDelete}" ; then
         target="${line}"
      else
         sources+=("${line}")
      fi
   fi
done
openSUSE Build Service is sponsored by