Results 1 to 6 of 6
Hi,
I would like to know if 'rm' command can be used to remove particular type of files recursively from a directory or partition?
The reason I'm asking is that ...
- 08-23-2008 #1Just Joined!
- Join Date
- Nov 2007
- Location
- Bangalore, India
- Posts
- 27
rm to work on particular type of files recursively on a directory/partition
Hi,
I would like to know if 'rm' command can be used to remove particular type of files recursively from a directory or partition?
The reason I'm asking is that my pen drive is infected by a virus. I call it 'folder' virus. The virus creates an 'exe' file by the name of the folder/directory. The more folders you have the more trouble you are in. Of course I can use an anti-virus on windows, but I want to delete them from command line in linux.
lists all those exe files in my pendrive. But I'm not able to delete them with same ease. I did,Code:ls /media/SV | grep exe
and expected that all the files with extension 'exe' will get deleted. It asked for confirmation once and I don't know what I typed. It gave an error "cannot delete /media/SV..." and came to prompt. Only then I realized that everything in my pendrive is deleted. Thankfully I had backed up the content on my hd.Code:rm -r /media/SV/*.exe
I think 'rm' interpreted it as to remove the directory /media/SV instead of the 'filter' I set.
What is the correct format to do what I want to do?
Regards,
SV
- 08-24-2008 #2
there is no problem with the command you ran( even though you dont need the -r here given that you are deleting only files).
if you want it to delete without confirmation you just do
Code:rm -f /media/SV/*.exe
Linux and me it's a love story
- 08-24-2008 #3Just Joined!
- Join Date
- Nov 2007
- Location
- Bangalore, India
- Posts
- 27
Then why did my whole pen drive got wiped out. I don't remember typing anything extra...
- 08-24-2008 #4
its not easy to tell you why that happened without having seen all that went on. maybe you can browse your history and see what you really did
Linux and me it's a love story
- 08-24-2008 #5Just Joined!
- Join Date
- Nov 2007
- Location
- Bangalore, India
- Posts
- 27
ok. may be i can try the same command on a test directory... some also instructed me to try out 'find, exec, xargs' options. will go thru man pages for them too.
thanks a lot buddy...
- 08-24-2008 #6
yeah find is safer given that you can run find to see if the result is what you want then you add -exec rm to remove them.
its a good idea going through the man pages.Linux and me it's a love story


Reply With Quote