It seems unlink doesn't work with wildcards in 2.5.0. I've tried R-2.5.0 under gnu/linux from source and the Mac binary from att research. Example: > dir() [1] "bgx.Rnw" "bgx.pdf" "run.1" > unlink("run.*",recursive=T) > dir() [1] "bgx.Rnw" "bgx.pdf" "run.1" > unlink("run.1",recursive=T) > dir() [1] "bgx.Rnw" "bgx.pdf" Cheers, Ernest
This is shell-dependent on a Unix-alike, but Sys.glob() should work. So try unlink(Sys.glob("run.*"), recursive=TRUE) On Wed, 25 Apr 2007, Ernest Turro wrote:> It seems unlink doesn't work with wildcards in 2.5.0. I've tried > R-2.5.0 under gnu/linux from source and the Mac binary from att > research. Example: > > > dir() > [1] "bgx.Rnw" "bgx.pdf" "run.1" > > unlink("run.*",recursive=T) > > dir() > [1] "bgx.Rnw" "bgx.pdf" "run.1" > > unlink("run.1",recursive=T) > > dir() > [1] "bgx.Rnw" "bgx.pdf"-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Ernest Turro wrote:> It seems unlink doesn't work with wildcards in 2.5.0. I've tried > R-2.5.0 under gnu/linux from source and the Mac binary from att > research. Example: > > > dir() > [1] "bgx.Rnw" "bgx.pdf" "run.1" > > unlink("run.*",recursive=T) > > dir() > [1] "bgx.Rnw" "bgx.pdf" "run.1" > > unlink("run.1",recursive=T) > > dir() > [1] "bgx.Rnw" "bgx.pdf" > >Yes. The argument is now passed through shQuote, and that has the side effect of removing wildcard expansions. If this was intentional, someone forgot to change the help page... Presumably, the change was done to prevent issues with embedded spaces: unlink("Program Files") would otherwise delete "Program" and "Files". It is not obvious to me how this can be achieved while retaining wildcard expansion. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907