In UNIX:
grep -rnw '.' -e 'texttosearch'
To search within the current directory '.' or 'path" to search in the path.
The options
-r means "recursive"
-e is the pattern to search for
-n Each output line is preceded by its relative line number in the file, starting at line 1.
-w The expression is searched for as a word (as if surrounded by ‘[[:<:]]’ and ‘[[:>:]]
Do not hesitate to do a man grep to see the dozens of options!
In R, a equivalent using "brut force" (without recursive option) is found in the package HelpersMG (https://CRAN.R-project.org/package=HelpersMG) :
inside(
text = stop("A text to be searched for is necessary"),
path = ".",
pattern = "*\\.R$",
showallfilenames = FALSE,
...,
fixed = TRUE,
ignore.case = FALSE
)
Aucun commentaire:
Enregistrer un commentaire