A program foo writes to an output file and prints diagnostic information to stdout.
Thus:
foo -o ./out -i ./input > log
results in the valuable stuff in ./out and some mumbo jumbo in log.
I need to read ./out into another program (an R script I am writing).
The intermediate step of writing to file ./out and reading again is slow, and I need to do this for big ./out files, hundreds of times.
I would like to perform some kind of redirection so that foo writes to a file descriptor rather than a file ./out, which I can read into my script directly. But stdout is already used.
Here is what I tried:
in R:
library(data.table)
fread(cmd = "foo -o /dev/stdout -i ./input > /dev/null")
but I get an error:
File '/data1/tmp/RtmpkKIpBm/fileeb789130da8e3' has size 0. Returning a NULL data.table.