#!/bin/bash
if [ $# -lt 2 ]
then
echo More input is needed
echo "Usage0 [folder containing duplicated file] [original folder]"
exit 1
fi
ls $1>1
ls $2>2
tmp="$(comm -12 1 2|wc -l)"
if [ $tmp -eq 0 ]
then
echo no common files
else
echo This will remove all common files in $1 when compared two folders
echo Common files are
comm -12 1 2 |tee $1/3
cd $1
rm -i $(cat 3)
rm 3
cd -
echo Removal complete
fi
rm 1 2