remove_lines | R Documentation |
Delete lines from a file programmatically, for example from ‘.gitignore’.
remove_lines(
file_path = file.path(".", ".gitignore"),
pattern,
overwrite = !fritools::is_false(getOption("packager")[["force"]])
)
file_path |
Path to the file. |
pattern |
A character vector of patterns. |
overwrite |
Overwrite the file on disk? |
Used for its side effects, returns the lines to be left in the file.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.