insertstring - UDM Command

Syntax

insertstring variable_name sequence {pos=position | startseq=sequence startseqnum=number} [case=yes|no]

Description

The insertstring command inserts a substring into an existing string.

The first parameter, variable_name, is the name of the existing variable or list element into which to insert the sequence.

The second parameter, sequence, specifies the sequence to be inserted.

The insertion point of the sequence is either:

  • By position (specified by the pos parameter)
  • At the character immediately following the instance of a given sequence (startseq specifies the sequence and startseqnum gives the instance).

The optional case parameter specifies whether the comparison used to find the start sequence is case-sensitive (yes) or case-insensitive (no). [II:Default is no.]

If the start sequence is given and could not be found, _lastrc.message will contain NO_MATCH. If a position is given and invalid, _lastrc.message will contain INVALID_VALUE.

Parameters

Parameter

Description

variable_name

Name of the existing variable or list element into which to insert the sequence.

sequence

Sequence to be inserted.

pos=position

Position at which sequence is inserted.

startseq=sequence

Sequence after which specified sequence is inserted.

startseqnum=number

Instance of sequence after which specified sequence is inserted.

case=yes | no

Specification of whether or not the comparison used to find the start sequence is case-insensitive.

Default is no.

Example

The following examples show how the insertstring command can be used on a preexisting variable called mystring with a starting value of This is a string:

insertstring mystring " sample" pos=10
echo "$(mystring)"
This is a sample string

insertstring mystring "sample " startseq=" " startseqnum=3
echo "$(mystring)"
This is a sample string