Click to See Complete Forum and Search --> : advanced rm command?


delryn
02-28-2005, 03:07 PM
Curious about the possibility

I have a few programs that I would like to remove (I stupidly removed the source)

I am wondering if there is a command or a script that will remove all files found by, say slocate, in one sweep from all directories.

or can someone point me in the right direction to have the output of slocate fed into a rm -r command

tia

Jata
02-28-2005, 03:16 PM
I don't know of any advanced rm command to be honest but I'd be very careful about using slocate to remove files. It can bring up unexpected matches and if you remove everything it produces you could well end up buggering up other programs.
I'd say your best bet would be to download the source again and then run the uninstall that would most likely come with it.

DrChuck
02-28-2005, 03:31 PM
I agree with jata, be careful when executing a powerful rm command, especially as root. Suggest you use "rm -i" to confirm each removal. But to answer your question:
<command> $(locate pattern)
will substitute the output of locate, as if you typed those matches right onto the command line. This won't work if any of the file matches contain whitespace.

You can also use back-tics for command substitution:
<command> `locate pattern`

drChuck

retsaw
02-28-2005, 04:19 PM
It's also possible to use use "find" to execute a command on every file it finds. I would be very careful about removing any programs by hand as you may accidentally removing something that is needed by another program.

AdamZ
02-28-2005, 05:05 PM
Yeah, the best way to remove it would be to download the source again. Then run ./configure, then make uninstall.

sharth
02-28-2005, 05:15 PM
Originally posted by blargety
Yeah, the best way to remove it would be to download the source again. Then run ./configure, then make uninstall. /me agrees.

bwkaz
02-28-2005, 08:04 PM
Originally posted by blargety
Then run ./configure, then make uninstall. Assuming you use all the same options for ./configure that you used last time, that is...

If you use a different --prefix (say, you used --prefix=/opt/package first time, and you don't use any --prefix the second time), hopefully nothing will be removed. But it's also possible that a boatload of distro installed files will be removed, if you use --prefix=/usr the second time.

Other options, like --sysconfdir, also control where the package puts its files, so they'll also control where it looks when it tries to delete stuff.

soulestream
02-28-2005, 08:15 PM
speaking as someone who did a rm -r on a users home directory the other day to remove all files in it and forgot the server was mounted as a rw mountpoint on the desktop, definetaly use the -i if your going to try that.



soule:(