RSUB(1) General Commands Manual RSUB(1)

rsubsubstitute lines or block of text

rsub [-A] -r line_regex -l line_text target

rsub target < block_content

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:

Append line if the pattern is not found.
A regular expression matching the line to replace.
The replacement text for a matching line. Newlines are not permitted as part of the replacement string.

When updating a block of text, RSUB_START and RSUB_END define the beginning and ending markers.

The rsub utility exits with one of the following values:

Target file was updated
No changes were made, or an error occurred
Incorrect parameters
File not found

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

awk(1), rinstall(1)

September 24, 2024 OpenBSD 7.6