#!/bin/bash list=fileList150719 # $list include the name of all the files in the current directory. searchdir=/media/kingsoftUSB/reportrenamed # This executable file searches file the name of which is in $list under the directory $searchdir . # If there is such file, its content is compared with the contents of the file in the current directory. # If the contents are the same, the information (permission, owner, group, size, modified time, path) of both files are written to $logfile and the file in $searchdir is deleted. logfile=/media/kingsoftUSB/movedtoITOusb # If the found file in $searchdir is symbolic link, the linked file is compared. # If the contents of the linked file is same as the contents of the file in the current directory, the information (permission, owner, group, size, modified time, path) of both files are written to $logfile and both of the symbolic link and the linked file are deleted. cat $list|while read path;do comppath=$(readlink -e $searchdir/"$path" 2>/dev/null) if [ -n "$comppath" ];then if [ -z "$(diff -aq "$path" "$comppath")" ];then ls -la "$path" >> $logfile ls -la "$comppath" >> $logfile echo >> $logfile rm -f "$comppath" rm -f $searchdir/"$path" fi fi done