jakob r jakob r - 6 months ago 21
Bash Question

Call shell skript with specific working directory from R

I have an sh script, that can only be run from a specific directory because it looks for the files in that directory and I don't want to change the sh file.

Suppose the file is in

and the R working directory is

What works is

wd = getwd()

But I find that rather unhandy. How can I do without changing the R working direcotry?


As system2 uses shQuote we can only use system() and as already pointed out by @Dirk you can then use

system("cd ./sub && sh script.sh")