Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s-fleck/sifr
Sarch and replace in files
https://github.com/s-fleck/sifr
Last synced: 10 days ago
JSON representation
Sarch and replace in files
- Host: GitHub
- URL: https://github.com/s-fleck/sifr
- Owner: s-fleck
- License: other
- Created: 2018-04-18T09:37:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T07:54:50.000Z (about 1 year ago)
- Last Synced: 2024-12-01T12:47:17.830Z (11 days ago)
- Language: R
- Homepage:
- Size: 57.6 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - s-fleck/sifr - Sarch and replace in files (R)
README
---
output: github_document
editor_options:
chunk_output_type: console
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "140%"
)
```
# sifr: search in files[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
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](https://en.wikipedia.org/wiki/Sed).## Installation
And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("s-fleck/sifr")
```
## Example```{r 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)
```