knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "140%"
)

sifr: search in files

Lifecycle: maturing

sifr is a tool for searching text strings and regular expression patterns recursively in directory trees from within R. It is mainly a convenience utility for interactive use.

sifr supports colored console output, RStudio source markers, and can also return the search results as a data.frame for further processing. In addition, sifr provides sed_replace() on supported platforms (such as Linux, BSD, macOS) for replacing regex patterns across directory trees via sed.

Installation

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("s-fleck/sifr")

Example

library(sifr)

tf <- tempfile(fileext = ".csv")
write.csv(cars, tf)

x <- sif("26", dir = dirname(tf), markers = FALSE, path_pattern = ".*\\.csv$")
print(x)
as.data.frame(x)


sed_replace("26", "twentysix", dir = dirname(tf), path_pattern = ".*\\.csv$")
sif("26", dir = dirname(tf), markers = FALSE, path_pattern = ".*\\.csv$")
sif("twentysix", dir = dirname(tf), markers = FALSE, path_pattern = ".*\\.csv$")
unlink(tf)


s-fleck/sifr documentation built on Oct. 15, 2023, 5:04 a.m.