i have variable that i used to represent duplicated files found in a certain directory
ddub=`find $1* -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} find -type f -size {}c -print0 `
I then looped over this directory to compare hard link any duplicates to the original file as well
echo $ddub #Print the results
for i in $ddub; do
for j in $ddub ; do
if cmp -s "$i" "j" ; then
ln $i $j
elif ;
echo "csnt hardlink the files"
fi
The problem here is that it tries to hard link every single file in the list which doesn't work as i would like to. I would like to separate the unique files from the rest and then hard link them.
How do i further loop over this so as to hardlink only similar MD5sum files found in the list or files with the same size?
the results i get are as follows which is just the list of all the files i created. please help me figure out how i can seperate them further (note i just created random files)
ln ./test_dir/test_dir2/29.JPG.copy.copy.copy.copy./test_dir/test_dir2/29.JPG.copy.copy.copy./test_dir/test_dir2/29.JPG.copy.copy.copy.copy.copy./test_dir/29.JPG./test_dir/29.JPG.copy./test_dir/29.JPG.copy.copy./test_dir/test_dir2/23.JPG.copy.copy.copy.copy./test_dir/test_dir2/23.JPG.copy.copy.copy.copy.copy./test_dir/09.JPG.copy./test_dir/09.JPG./test_dir/09.JPG.copy.copy./test_dir/39.JPG./test_dir/39.JPG.copy./test_dir/test_dir2/22.JPG.copy.copy.copy.copy./test_dir/test_dir2/22.JPG.copy.copy.copy.copy.copy./test_dir/test_dir2/22.JPG.copy.copy.copy./test_dir/22.JPG./test_dir/22.JPG.copy.copy./test_dir/22.JPG.copy ./test_dir/test_dir2/29.JPG.copy.copy.copy.copy./test_dir/test_dir2/29.JPG.copy.copy.copy./test_dir/test_dir2/29.JPG.copy.copy.copy.copy.copy./test_dir/29.JPG./test_dir/29.JPG.copy./test_dir/29.JPG.copy.copy./test_dir/test_dir2/23.JPG.copy.copy.copy.copy./test_dir/test_dir2/23.JPG.copy.copy.copy.copy.copy./test_dir/09.JPG.copy./test_dir/09.JPG./test_dir/09.JPG.copy.copy./test_dir/39.JPG./test_dir/39.JPG.copy./test_dir/test_dir2/22.JPG.copy.copy.copy.copy./test_dir/test_dir2/22.JPG.copy.copy.copy.copy.copy./test_dir/test_dir2/22.JPG.copy.copy.copy./test_dir/22.JPG./test_dir/22.JPG.copy.copy./test_dir/22.JPG.copy
[asonganyif@ccad2 November_2016]$ vim bashScripass.sh