Portal Home > Knowledgebase > Articles Database > how to find and Delete specific file via ssh
how to find and Delete specific file via ssh
Posted by rcpkrc, 05-30-2012, 05:18 AM |
hello mates, l want to find and delete filename.fileextention from /home directory of my dedicated server. how is it possible can some1 share?
|
Posted by gigatux, 05-30-2012, 05:50 AM |
To find: find /home -name filename.fileextension
To delete: rm the file
To do both at the same time: find /home -name filename.fileextension |xargs rm
Or, possibly even better, find /home -name filename.fileextension -exec rm {} \;
|
Posted by netmultiple, 05-30-2012, 06:03 AM |
use "cd" to directory that file contain and use "rm filename.ext" to delete
|
Posted by rcpkrc, 05-30-2012, 10:57 AM |
I am tring your commands but it takes too much time why ?
|
Posted by gigatux, 05-30-2012, 11:07 AM |
Probably because you have loads of files and directories in /home
If you need to check it's actually doing something, change the 'rm' bit to 'ls' and you'll see the files it was searching (although it obviously won't do much else).
|
Posted by bear, 05-30-2012, 11:15 AM |
That's a good idea no matter how many files, to make sure it's grabbing only the desired ones. When using something automated like that, the odds of a small error causing havoc are much higher. Just sayin'
|
Add to Favourites Print this Article
Also Read
iracks down? (Views: 650)