Invoke a command in the system command-line shell

shell(command, args = "", stdout = "", stderr = "", ...)






stdout, stderr

character(1), logical(1), or NULL. Where output to stdout or stderr should be sent.

Possible values:

  • "": Output to the R console.

  • FALSE or NULL: Discard the output.

  • TRUE: Capture the output in a character vector.

  • character(1): Capture the output in a defined file name.


Passthrough arguments to system2().


If stdout = TRUE or stderr = TRUE, a character vector giving the output of the command, one line per character string. If the command could not be run, an R error is generated. If command runs but gives a non-zero exit status this will be reported with a warning and in the attribute "status" of the result.

In other cases, the return value is an invisible error code (0 for success). If the command could not be run for any reason, the value is 127 and a warning is issued. If the command times out, a warning is issued and the exit status is 124.


Updated 2020-08-09.

See also

  • system2.


shell(command = "echo", args = c("hello", "world"))