Delete hidden files on unix

subeen tamim.shahriar at gmail.com
Mon Mar 3 09:38:06 EST 2008


On Mar 3, 6:13 pm, Philipp Pagel <pDOTpa... at helmholtz-muenchen.de>
wrote:
> loial <jldunn2... at googlemail.com> wrote:
> > How can I delete hidden files on unix with python, i.e I want to do
> > equivalent of
> > rm  .lock*
>
> Here is one way to do it:
>
> import os, glob
> for filename in glob.glob('.lock*'):
>     os.unlink(filename)
>
> Alternatively, you could also do this:
>
> import os
> os.system('rm .lock*')
>
> cu
>         Philipp
>
> --
> Dr. Philipp Pagel
> Lehrstuhl f. Genomorientierte Bioinformatik
> Technische Universität Münchenhttp://mips.gsf.de/staff/pagel

Another way is to execute the linux command directly :)
Check here: http://love-python.blogspot.com/2008/02/execute-linux-commands-in-python.html

regards,
subeen.
http://love-python.blogspot.com



More information about the Python-list mailing list