I want to delete the duplicate files from two directories. The structure of the directories and files are as follows
nijat@nijat-virtual-machine:~/mansoor$ mkdir dir1
nijat@nijat-virtual-machine:~/mansoor$ mkdir dir2
nijat@nijat-virtual-machine:~/mansoor$ ls
dir1 dir2
nijat@nijat-virtual-machine:~/mansoor$ cd dir1
nijat@nijat-virtual-machine:~/mansoor/dir1$ touch myfile.txt
nijat@nijat-virtual-machine:~/mansoor/dir1$ ls
myfile.txt
nijat@nijat-virtual-machine:~/mansoor/dir1$ cd ..
nijat@nijat-virtual-machine:~/mansoor$ cd dir2
nijat@nijat-virtual-machine:~/mansoor/dir2$ touch myfile.txt
nijat@nijat-virtual-machine:~/mansoor/dir2$ ls
myfile.txt
I have tried to delete the duplicate file from both dir1
and dir2
. For this I have written the following command.
nijat@nijat-virtual-machine:~/mansoor$ fdupes -d dir1 -r dir2
[1] dir1/myfile.txt
[2] dir2/myfile.txt
Set 1 of 1, preserve files [1 - 2, all]: all
[+] dir1/myfile.txt
[+] dir2/myfile.txt
nijat@nijat-virtual-machine:~/mansoor$ fdupes -d dir1 -r dir2
[1] dir1/myfile.txt
[2] dir2/myfile.txt
Set 1 of 1, preserve files [1 - 2, all]: 2
[+] dir1/myfile.txt
[-] dir2/myfile.txt
nijat@nijat-virtual-machine:~/mansoor$ cd dir1
nijat@nijat-virtual-machine:~/mansoor/dir1$ ls
myfile.txt
nijat@nijat-virtual-machine:~/mansoor/dir1$ cd ..
nijat@nijat-virtual-machine:~/mansoor$ cd dir2
nijat@nijat-virtual-machine:~/mansoor/dir2$ ls
nijat@nijat-virtual-machine:~/mansoor/dir2$
But the problem is that I don't know what option I have to select to delete both files from both directories.
Set 1 of 1, preserve files [1 - 2, all]:
I have tried different options, for example, I give all to delete all files but nothing happens. When I select 1
it deletes the file from dir1
but the file remains in the dir2
if I select 2
the file will be deleted from dir2
but it will not be deleted from dir1
.
I also tried to delete both files from both directories without asking me. I use the following command
nijat@nijat-virtual-machine:~/mansoor$ fdupes -dN dir1 -r dir2
[+] dir1/myfile.txt
[-] dir2/myfile.txt
nijat@nijat-virtual-machine:~/mansoor$ cd dir2
nijat@nijat-virtual-machine:~/mansoor/dir2$ ls
nijat@nijat-virtual-machine:~/mansoor/dir2$ cd ..
nijat@nijat-virtual-machine:~/mansoor$ cd dir1
nijat@nijat-virtual-machine:~/mansoor/dir1$ ls
myfile.txt
As you can see my file still exists in dir1
. Please help me with this, I just want to delete both files from both directories at the same time without confirmation.