search_files: Search Files for a Pattern

View source: R/search_files.R

search_filesR Documentation

Search Files for a Pattern

Description

This is an approximation of unix find and grep.

Usage

search_files(what, verbose = TRUE, exclude = NULL, ...)

Arguments

what

A regex pattern for which to search.

verbose

Be verbose?

exclude

A regular expression for excluding files.

...

Arguments passed to list.files.

Value

Invisibly a vector of names of files containing the pattern given by what.

See Also

Other searching functions: compare_vectors(), file_modified_last(), find_files(), fromto(), grep_file(), missing_docs, search_rows(), summary.filesearch()

Other file utilities: clipboard_path(), delete_trailing_blank_lines(), delete_trailing_whitespace(), develop_test(), file_copy(), file_modified_last(), file_save(), find_files(), get_lines_between_tags(), get_mtime(), get_unique_string(), grep_file(), is_files_current(), is_path(), paths, split_code_file(), touch()

Examples

write.csv(mtcars, file.path(tempdir(), "mtcars.csv"))
 for (i in 0:9) {
     write.csv(iris, file.path(tempdir(), paste0("iris", i, ".csv")))
 }
search_files(what = "Mazda", path = tempdir(), pattern = "^.*\\.csv$")
search_files(what = "[Ss]etosa", path = tempdir(), pattern = "^.*\\.csv$")
x <- search_files(path = tempdir(),
                  pattern = "^.*\\.csv$",
                  exclude = "[2-9]\\.csv$",
                  what = "[Ss]etosa")
summary(x)
summary(x, type = "what")
summary(x, type = "matches")
try(search_files(what = "ABC", path = tempdir(), pattern = "^.*\\.csv$"))

fritools documentation built on Nov. 19, 2023, 1:06 a.m.