cleanup a directory
Hello List, to clean some directories of mine, I use rm -rf * but files named as `.log' are not removed. Is there a better way to do so ? Thanks in advance, Jerome -- Jerome BENOIT jgmbenoit_at_mailsnare_dot_net -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: cleanup a directory
Hello List, to clean some directories of mine, I use rm -rf * but files named as `.log' are not removed. Is there a better way to do so ? Thanks in advance, Jerome Your problem is that the shell doesn't expand the '*' to hidden files. You could do '.*', but that would match '..' and '.' too. Your could rm -rf the whole directory and then mkdir it again. Otherwise find . -depth -mindepth 1 -exec rm '{}' \; could do the job. Christopher pgpPMbGa0bDQR.pgp Description: PGP signature
Re: cleanup a directory
Jerome BENOIT wrote: Hello List, to clean some directories of mine, I use rm -rf * but files named as `.log' are not removed. Is there a better way to do so ? Go to the previous directory and then remove the directory using rm -rf. This will remove other hidden files along with the .log files. I tend to resist the use of * when using rm -rf. I usually work with a lot of terminals open (inside konsole). So the probability of being in the wrong directory and removing its contents is large if I use '*' with rm -rf. But when the directory name is explicitly specified, the probability of removing the wrong directory is small. YMMV. hth raju -- Kamaraju S Kusumanchi http://www.people.cornell.edu/pages/kk288/ http://malayamaarutham.blogspot.com/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: cleanup a directory
On 02/27/2008 09:39 AM, Jerome BENOIT wrote: to clean some directories of mine, I use rm -rf * but files named as `.log' are not removed. Dot files are not expanded by * - to remove just the .log files, for example: find ./ -type f -name .log -exec rm -rf {} \; To remove everything in $PWD, similar to rm -rf: find ./ -exec rm -rf {} \; These are just quick examples - find has many powerful options to make the above much safer - be careful.. ;) -- Kind Regards, Michael -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]