Paillou
Paillou

Reputation: 839

Is there a way to import a R variable into a linux script?

I have a Rscript which generates several variables. I would like to import one of these variables into a bash loop? Is it possible?

My variable is variable and I want to import it like this :

for i in variable
do <command line>
done 

I do not want to save variable into a file and reload this .

Is there a solution?

Upvotes: 1

Views: 72

Answers (1)

damienfrancois
damienfrancois

Reputation: 59110

You can have the R script print out the content of the variable and use a construct like this:

VAR=$(Rscript myscript.R)
for i in $VAR
do <command line>
done 

Upvotes: 1

Related Questions