Command Line Tricks, Tips, Hacks and How To's
Easily Remove Duplicate Directories or files
If you have managed to create identical files or worse still directories or even worse still a directory with the same name as you home directory and cannot gain access to list both files to assertain which one to delete as the system will see them as the same file or directory, you can simple remove the offending file or directory by doing the following from the command line.
*****PLEASE NOTE THAT IN THIS SCENARIO YOU CANNOT SIMPLY USE THE rm COMMAND TO DELETE THE FILE AS YOU WOULD NORMALLY. IF YOU DO YOU MAY DELETE THE WRONG FILE OR DIRECTORY. YOU HAVE BEEN WARNED*****
First use the following command at the commanline prompt:
ls -il
This will list all of the directories and files within the current directory alongside the inode number. This is normally shown in the first left-hand column. Make a note of this number
Using your linux "root", "sudo" or BSD "Doas" account use the following command:
find . -inum
This will ask you if you wish to delete the required file. Answer yes and the file will be deleted. Job done.