Author Topic: Delete a folder (& contents) without knowing location  (Read 228 times)

0 Members and 1 Guest are viewing this topic.

Offline pooky2483

  • Hero Member
  • *****
  • Posts: 2103
  • Karma: 0
  • Gender: Male
  • Slowly getting the hang of it.
    • View Profile
    • Awards
Delete a folder (& contents) without knowing location
« 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.

Kubuntu 16.04LTS 64bit|KDE 5.36.0|QT 5.6.1|Linux 4.15.0-39-generic|M5A78L-M USB3|BIOS 2101|AMD PhenomII X4 965 3400+|P8H77-I Motherboard NIC|32.0GB PC3-10600 1333Mhz CL9 ( 9-9-9-24 ) DDR3

Offline Keith

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1036
  • Karma: 13
  • Gender: Male
  • Linux Novice
  • Awards Contributor Of The Month
    • View Profile
    • Awards
Re: Delete a folder (& contents) without knowing location
« Reply #1 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:
Code: [Select]
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: 
Code: [Select]
find {directory name} 
then:
Code: [Select]
rm -r {path to directory}
Works for me, anyway.

Keith
« Last Edit: February 21, 2020, 03:14:18 pm by Keith »

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal