The Linux.uk Community Forum

General Help & Advice => Linux Support => Topic started by: pooky2483 on February 20, 2020, 09:30:32 PM

Title: Delete a folder (& contents) without knowing location
Post by: pooky2483 on February 20, 2020, 09:30:32 PM
Is it possible to delete a folder and it's contents without knowing it's location.
I need to do this to remove config files and other traces of a previously installed program so I can reinstall without the program using old config files not removed during --purge.
Title: Re: Delete a folder (& contents) without knowing location
Post by: Keith on February 21, 2020, 12:05:34 PM
 If you can remember part of the directory name then one can use the find command.
Here's a test example:
mkdir mydirectory
echo "data" > mydirectory/newfile
ls mydirectory
rm -r $(find -iname *direc* )
ls mydirectory

If you can specify the whole directory name then you don't need the "-iname".  Perhaps you'll need sudo for your config file.
So to check that there is only one directory of that name:  find {directory name}
then:
rm -r {path to directory}
Works for me, anyway.

Keith