[R] Utility function to rotate log files?

Henrique Dallazuanna wwwhsd at gmail.com
Fri Nov 13 20:35:13 CET 2009


You can try something about like this:

foo <- function() {
	unlink("file3.txt")
	file.rename("file2.txt", "file3.txt")
	file.rename("file1.txt", "file2.txt")
	sink("file1.txt")
	cat("test file1")
	sink()
}




On Fri, Nov 13, 2009 at 5:20 PM, Don MacQueen <macq at llnl.gov> wrote:
> I am wondering if there is a CRAN package that includes a utility function
> that will "rotate" file names, in the same sense that operating systems
> sometimes rotate log files. Or maybe there's something in base R.
>
> That is, we have a set of file names, say file1, file2, file3, and when the
> function is called, file3 is deleted, file2 is renamed file3, file1 is
> renamed file2, and the name of file1 is returned to the user's script, which
> then writes to file1.
>
> I've done some searching (RSiteSearch) but haven't found anything.
>
> Thanks
> -Don
> --
> --------------------------------------
> Don MacQueen
> Environmental Protection Department
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list