Manpage logo

rsub - substitute lines or block of text


RSUB(1) General Commands Manual RSUB(1)

NAME

rsub — substitute lines or block of text

SYNOPSIS

rsub [−A] −r line_regex −l line_text target
rsub
target < block_content

DESCRIPTION

rsub is shipped to remote machines by rset(1) to provide a standard method of modifying configuration parameters within a file. Two modes of operation are supported: line substitution and block replacement.

Single line replacements are defined by the flags −r and −l, while the content for a text block is provided on STDIN.

The arguments for line substitution are as follows:

−A

Append line if the pattern is not found.

−r

A regular expression matching the line to replace.

−l

The replacement text for a matching line. Newlines are not permitted as part of the replacement string.

ENVIRONMENT
RSUB_DIFF_ARGS

Arguments for diff(1) tool. The default is "-U 2".

RSUB_START RSUB_END

Define the beginning and ending markers when updating a block of text.

EXIT STATUS

The rsub utility exits with one of the following values:

0

Target file was updated

1

No changes were made, or an error occurred

2

Incorrect parameters

3

File not found

EXAMPLES

Ensure a single configuration parameter is set

$SD/rsub -r ’ˆAllowTcpForwarding .+’ -l ’AllowTcpForwarding yes’ \

/etc/ssh/sshd_config

Update a managed block of text

$SD/rsub /etc/fstab <<-CONF
/dev/ada0p1 /vm ufs rw 0 0
CONF

SEE ALSO

awk(1), rinstall(1) GNU February 6, 2025 RSUB(1)


Updated 2026-06-01 - jenkler.se | uex.se