Is there a Bash command or series of commands which will identify and remove replicated directories?
1
vote
0
answers
43
views
I'm working on a developing a script which will, inside of a directory, verify the existence of a sub-directory, then locate and delete replicated copies in the same directory. For example:
A directory has the following sub-directory added:
FLDR6544_8765
Other copies of the folder are replicated, such as:
FLDR6544_8765-0
FLDR6544_8765-1
FLDR6544_8765-2
Is there a command or scripted series of commands which will verify the existence of the original folder (in the example FLDR6544_8765
), then remove the replicated folders (FLDR6544_8765-0
, FLDR6544_8765-1
, FLDR6544_8765-2
)
I can use
find -type d -name "-0" exec rm -r {} \; -prune
to find the directories with the replicated endings (-0, -1, etc), but that doesn't ensure the original file exists before deleting the replicated copies.
Thanks in advance for any ideas you might have!
Asked by William Hauk
(11 rep)
Apr 16, 2021, 02:45 PM
Last activity: Apr 16, 2021, 02:49 PM
Last activity: Apr 16, 2021, 02:49 PM