remove_lines {packager} | R Documentation |
Remove Lines From a File
Description
Delete lines from a file programmatically, for example from ‘.gitignore’.
Usage
remove_lines(
file_path = file.path(".", ".gitignore"),
pattern,
overwrite = !fritools::is_false(getOption("packager")[["force"]])
)
Arguments
file_path |
Path to the file. |
pattern |
A character vector of patterns. |
overwrite |
Overwrite the file on disk? |
Value
Used for its side effects, returns the lines to be left in the file.
Examples
temp_file <- file.path(tempdir(), ".gitignore")
content <- c("doc", "Meta", ".RData", "*.tar.gz", "doc/*")
cat(content, sep = "\n")
writeLines(content, temp_file)
cat(remove_lines(temp_file, c("^doc$", "^doc/.*$")), sep = "\n")
cat(readLines(temp_file), sep = "\n")
[Package packager version 1.15.3 Index]