kkobayashi #7009(2008/08/06 15:40 GMT) [ R ] Rating0/0=0.00
まじめに書いたらCのようになってしまいました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
read.file <- function (infile, offset=0){ con <- file(infile) open(con) seek(con, offset) lines <- readLines(con) cur.offset <- seek(con) close(con) list(l=lines, o=cur.offset) } my.tail <- function(infile, n=10, follow=FALSE){ lines <- read.file(infile) writeLines(tail(lines$l, n)) if(follow){ size <- file.info(infile)$size repeat{ if(size < (s <- file.info(infile)$size)){ lines <- read.file(infile, lines$o) writeLines(lines$l) size <- s } Sys.sleep(1) } } }
Rating0/0=0.00-0+
[ reply ]
kkobayashi
#7009()
[
R
]
Rating0/0=0.00
まじめに書いたらCのようになってしまいました。
read.file <- function (infile, offset=0){ con <- file(infile) open(con) seek(con, offset) lines <- readLines(con) cur.offset <- seek(con) close(con) list(l=lines, o=cur.offset) } my.tail <- function(infile, n=10, follow=FALSE){ lines <- read.file(infile) writeLines(tail(lines$l, n)) if(follow){ size <- file.info(infile)$size repeat{ if(size < (s <- file.info(infile)$size)){ lines <- read.file(infile, lines$o) writeLines(lines$l) size <- s } Sys.sleep(1) } } }Rating0/0=0.00-0+
[ reply ]