在Ubuntu的R studio中调用shell脚本

在Ubuntu的R studio中调用shell脚本,r,shell,ubuntu,R,Shell,Ubuntu,我不熟悉Ubuntu/LINUX中的shell脚本。我需要阅读/path/raw/hourly/中的所有文件夹,并阅读NLDAS\u VIC0125\u H.A*.grb 我的做法如下: startingDir <- "/path/raw/hourly/" thepattern <- "NLDAS_VIC0125_H.A*\\.grb" files <- list.files(path = startingDir, pattern=thepattern, recursive=T

我不熟悉Ubuntu/LINUX中的shell脚本。我需要阅读
/path/raw/hourly/
中的所有文件夹,并阅读
NLDAS\u VIC0125\u H.A*.grb

我的做法如下:

startingDir <- "/path/raw/hourly/"
thepattern <- "NLDAS_VIC0125_H.A*\\.grb"
files <- list.files(path = startingDir, pattern=thepattern, recursive=T, full.names=T)
我在下面尝试了这段代码,但它没有产生输出

for (f in files) {
  system(paste('#!/bin/bash','cdo -f nc copy', substr(f,10,47), '/file/path/out/${', substr(f,10,43), '%.grb}.nc'))
}
感谢您的帮助


谢谢。

既然您在R中,您可以在R中自己编写脚本。类似于:
for(f in files)system(粘贴('cdo-f nc copy',startingDir,f',/file/path/out/${',f',}.nc'))
谢谢,但它返回“错误替换”。
for (f in files) {
  system(paste('#!/bin/bash','cdo -f nc copy', substr(f,10,47), '/file/path/out/${', substr(f,10,43), '%.grb}.nc'))
}