Skip to content

about sink and scan

1 message · Michael S

#
Hi All r-helper,

my question like this:
I use "sink" function to get output into one file,during the sink process , 
output keep writing into this file,I want to check is there any new output 
write into this file(which "sink function create"), using "scan" function to 
read new output from that file.
if I use the cat with "\n" ,and scan(....,skip=linenumber) ,I can get what I 
want.but I just use "cat" without "\n",every new output just append at the 
end of last output. I can not use skip option in scan function . what should 
I do ?
I know file.info(..)$size can get current size of file. but how can I check 
which is new output or old one within the same line ,then scan the latest.

example:
sink('test.txt')
cat("r sink")
scan('text.txt',what='character',blank.lines.skip=FALSE,sep='\\n',skip=0,quiet=TRUE)
cat("htuierghtue")
scan#this time I just want to scan the "htuierghtue"
sink()

thanks in advance