Hi, I need to capture the output in a physical file when I run an R script. I would like to capture the output as a TXT file. I am thinking something along the line of the tee command is what I am after, but I am not certain what I am after here. https://en.wikipedia.org/wiki/Tee_(command) https://www.gnu.org/software/coreutils/manual/html_node/tee-invocation.html Here is a syntax example of how I use the tee command on other efforts of life: /bin/bash ./BackUp_script-v3.sh | tee -a ~/Desktop/script-run-Sunday-1.txt Here is a syntax example of how I am running my R scripts now: #R Studio Console #source("./process/script-name.r") #Bash Terminal #Rscript ./process/script-name.r QUESTIONS What command or function am I after to capture console and terminal output? It would be best to also define the character encoding and line ending parameters of the TXT file. How do I amend my existing script run syntax to capture the said outputs? Thanks, -- *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com <http://www.shdawson.com>
Dear Stephen, Maybe running R in batch mode is what you're after? E.g. running R CMD BATCH ./process/script-name.r creates ./process/script-name.Rout (or ./process/script-name.rout ?) with output of R commands and inline output, I think stderr (maybe others? Not only stdout like tee ... https://en.wikipedia.org/wiki/Standard_streams ) Note, the batch output is overwritten, as opposed to being appended to (the tee -a flag) the next time you run that line again ... Best, Rasmus