replace - UDM Command

Syntax

replace variable_name oldsequence newsequence [num=index] [all=yes|no] [case=yes|no]

Description

The replace command replaces one or more instances of a sequence with another sequence.

The first parameter, variable_name, is the name of an existing variable or list element on which to perform the replace. The oldsequence parameter specifies the sequence to be replaced. The newsequence parameter specifies the sequence replacing oldsequence.

The optional num parameter specifies a one-based sequence number that identifies the occurrence of the sequence that is replaced.

The optional all parameter indicates whether all instances of the old sequence are replaced (yes) or just the first instance encountered (no). If all is not specified, it is assumed that only the first instance is replaced.

If all equals yes, and num also is specified, num is ignored.








<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="1980c729-cec1-4392-8b0e-f1c06569f1f5"><ac:parameter ac:name="">1156191</ac:parameter></ac:structured-macro> The optional case parameter specifies whether the comparison to match the old sequence is case sensitive (yes) or case insensitive (no). [Default is no.]








Parameters

Parameter

Description

variable_name

Name of the existing variable or list element on which to perform the replace.

oldsequence

Sequence to be replaced.

newsequence

Sequence replacing oldsequence.

num=index

One-based sequence number that identifies the occurrence of oldsequence.

all=yes | no

Specification for whether all instances (yes) of the sequence are replaced or only the first instance (no) of the sequence.

case=yes | no

Specification for whether the comparison to match the old sequence is case sensitive (yes) or case insensitive (no).


<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="91cc27cf-fab3-4f22-9afc-0ff53b47d433"><ac:parameter ac:name="">1156223</ac:parameter></ac:structured-macro> [Default is no.]



Examples

The following examples use a predefined variable, mystring, with a value of abcabcabc.

replace mystring ab " " all=yes
echo "$(mystring)"
 c c c

replace mystring "abc" "123" num=1
echo "$(mystring)"
123abcabc