If I run an R script which contains a system function call similar to :
x<-system("ls -t -r | tail -n 1") ,
x will be 0 if the command is executed properly, different than 0 if there is an error. How can I save the output from the terminal in R, while executing the script?