title: how do you get the tail -50 of the remote file in R
body: <p>I need to be able to login to a system and get to get the tail -50 of the file. I have teh following set of code but this gets the whole file. Since the file is so huge, I need to run the script every 10 minutes and get the last 50 lines of the file. This is what I have:</p>
  
  <pre><code>library(RCurl)
  for(k in 1:2) {
       day1&lt;-day-k
       day1&lt;-format(day1, "%Y%m%d")
       day_vector&lt;-c(day_vector, day1)
  }
  
  servers&lt;-c("ServerA", "ServerB","ServerC")
  
    for (i in 1:length(servers)) {
      for(j in 1:length(day_vector)) {
      ser_day&lt;-paste(servers[i], day_vector[j], sep=".")
      url&lt;-paste0(servers[i], ".example.net/opt/files/appl_log_")
      url&lt;-paste(url, ser_day, sep="")
      url&lt;-paste0("sftp://", url)
  
      tryCatch({
  
               x&lt;-getURL(url, userpwd="account1:passwd1", connecttimeout=60)
               writeLines(x, paste0(servers[i], ".txt"))
              },error = function(e) 
              {
                      print("unable to get the file")
  
          })
  </code></pre>
  
  <p>Is there any way to get the tail of the file?</p>