I would like to do a safe file removal
Naturally, the command
rm -f /dir/*
I want to modify the command such that it does not delete files with extensions
.f, .c, .h, .par, .com
on 01/17/2013 – Made popular on 01/17/2013
Can I modify the rm command with regular expression or something to delete
every file in current directory except files with extensions *.bmp, *.wav and *.png? It should be case insensitive because there are files like *.BMP or *.bMP.
I wanted to delete all files with extension .dmp which are older than 60 days. So I executed rm command from within find as show below and it
deleted ALL THE FILES (even files without any extention) which the user had permission !!!!! Luckily this was a pre-production server.
Otherwise , this would have got me fired !!
I've no idea what is happening. I can run any other shell command through the exec() command and it works fine. It's clearly something to do with permissions somewhere, but I'm unsure what. I've tried this on many different servers and some of them work fine and some don't. All were running CentOS.