Reputation: 99331
Suppose I've discovered that in my package, a small piece of code needs to be changed and I cannot recall all the file names where that code may exist.
Is there a package development tool that can identify all the files that contain the problem code given the list of files in the R
folder?
Right now, for 14 files in the R directory I'm using
> c(sapply(list.files("R", full.names = TRUE), function(x){
grep("data/", readLines(x, warn = FALSE), value = TRUE)
}), recursive = TRUE)
# R/load-event.R
# " on.exit(file.remove(paste0(\"data/\", list.files(\"data\"))))"
But this could be time-consuming if the file list is long, and the files themselves are big.
Upvotes: 0
Views: 328
Reputation: 75575
It sounds like you are looking for grep
. The following command will list all files which contain the string data/
.
grep -l 'data/' R/*
Upvotes: 2