perl.oneliner: execute a perl one liner

Description Usage Arguments Details Value Author(s)

Description

execute a perl one liner, such as a regex search & replace (which is how i most often use this), eg s|^.+\t|| and execute it on the cmdline.

Usage

1
perl.oneliner(cmds, files, intern = FALSE, debug = FALSE)

Arguments

cmds

a character vector of commands

files

a character vector of paths to files. It is recyled to match the length of cmds

intern

logical: capture the output of the command as an R character vector?

debug

logical: if TRUE, print the oneliner command before executing it

Details

you can pass in multiple commands (such as multiple regex search/replace strings) applied to one or multiple files. i've tested the usage of multiple regex commands applied to a single file.

commands The commands vector can either contain the leading perl command, eg perl.oneliner("perl -pi -e 's|<DTG|\n <DTG|g'", file)
or just a pattern, eg
perl.oneliner("'s|<DTG|\n <DTG|g'", file)
in which case we will add the leading perl -pi -e

Value

nothing

Author(s)

Mark Cowley


drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.