You can use vcs::gsubr from here. if you just want to recursively grep use vcs::grepr, which also works on remote paths (ie github | bitbuck | svn)
dir.create(file.path(tempdir(), 'gsubr/d'),recursive = TRUE)
path_up <- tempfile(pattern = 'gsubr-',
fileext = '.txt',
tmpdir = file.path(tempdir(), 'gsubr'))
path_down <- tempfile(pattern = 'gsubr-',
fileext = '.txt',
tmpdir = file.path(tempdir(), 'gsubr/d'))
cat('this is a test',sep='\n',file = path_up)
cat('this is a test in the subdir',sep='\n',file = path_down)
list.files(tempdir(),recursive = TRUE)
#> [1] "gsubr/d/gsubr-e2e73edc688b.txt" "gsubr/gsubr-e2e7642ce2c6.txt"
vcs::gsubr(pattern = '\\bis\\b',
replacement = 'was',
path = tempdir(),
recursive = TRUE)
#> /var/folders/4_/xhs9__yd49l4v4j4wdg9f0wr0000gp/T//RtmpTw5R52/gsubr/d/gsubr-e2e73edc688b.txt
#> "[line 1] this was a test in the subdir"
#> /var/folders/4_/xhs9__yd49l4v4j4wdg9f0wr0000gp/T//RtmpTw5R52/gsubr/gsubr-e2e7642ce2c6.txt
#> "[line 1] this was a test"
vcs::gsubr(pattern = '\\bis\\b',
replacement = 'was',
path = tempdir(),
recursive = TRUE,
test = FALSE)
readLines(path_up)
#> [1] "this was a test"
readLines(path_down)
#> [1] "this was a test in the subdir"
unlink(file.path(tempdir(),'gsubr'),recursive = TRUE)
Created on 2018-05-10 by the reprex package (v0.2.0).