I have a bash script that is basically a series of commands to download a bunch of climate files. Among many other information on the script, lines 28 to 1027 determine the actual files that should be downloaded. See my file:
# point to file file <- 'https://dl.dropboxusercontent.com/u/27700634/wget-ESG-files.sh' # read file content r.lines <- readLines(con=file)
What I need to do is:
1) detect a pattern in the name of the files, subsetting only the files I really need to download. I can do this, see the code:
# choose variable name. # in this case, average monthly precipitation var <- 'pr_Amon' # find only the lines that contain my variable of interest new.r.lines <- r.lines[grepl(var, r.lines)] new.r.lines
2) now, what I need to do is replace all the contents of elements 28 to 1027 of the original file by the contents of the variable "new.r.lines". The result must be a vector as well, because by the end of the script I will use writeLines to create a new file.
This is probably a very easy task, but I'm just stuck in this step.
Any help is much appreciated!