aaa.R
Args <- commandArgs()
cat("Args[1]=",Args[1],"\n")
cat("Args[2]=",Args[1],"\n")
cat("Args[3]=",Args[3],"\n")
cat("Args[4]=",Args[4],"\n")
cat("Args[5]=",Args[5],"\n")
cat("Args[6]=",Args[6],"\n")
shell_cmd<-paste0("grep -n CHR ",Args[6])
grep_out<-system(shell_cmd, intern = TRUE)
cat(grep_out)
how to run:
/myPathToRscript/Rscript aaa.R bbb.vcf
=============================================
Description
system
invokes the OS command specified by command
.
Usage
system(command, intern = FALSE,
ignore.stdout = FALSE, ignore.stderr = FALSE,
wait = TRUE, input = NULL, show.output.on.console = TRUE,
minimized = FALSE, invisible = TRUE)
Arguments
| the system command to be invoked, as a character string. |
| a logical (not |
| a logical (not |
| a logical (not |
| if a character vector is supplied, this is copied one string per line to a temporary file, and the standard input of |
| arguments that are accepted on Windows but ignored on this platform, with a warning. |
=============================================
Invoke a System Command, using a Shell
Description
shell
runs the command specified by cmd
, usually under a shell.
Usage
shell(cmd, shell, flag="/c", intern=FALSE, wait=TRUE,
translate=FALSE, mustWork=FALSE, ...)
Arguments
| the system command to be invoked, as a string. |
| a string giving the name of the shell to be used, or |
| the switch to run a command under the shell. If the shell is |
| a logical, indicates whether to make the output of the command an R |
| should the R interpreter wait for the command to finish? The default is to wait, and the interpreter will always wait if |
| If |
| a logical; if |
REF:
http://astrostatistics.psu.edu/datasets/R/html/base/html/shell.html
https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.html