System Command with Space in R

2020-02-13 05:42发布

问题:

I run a system command with spaces in directory name as followed:

command=paste(shQuote("java -jar C:/DIR A/DF.jar -t"), t1, t2)

I tried also:

command=paste('"java -jar C:/DIR A/DF.jar -t"', t1, t2)

However I get the following:

Error in system(command, intern = TRUE) : 
  '"java -jar C://DIR A/DF.jar -t"' not found

How can I handle space in directory name in Windows?

回答1:

Here is the solution

command=paste('java -jar "C:/DIR A/DF.jar" -t', t1, t2)

use " only for the dir name and the outside with '



标签: r system space