Replacing Text in the Stack (.M)

The .M command modifies the top statement in the stack. It allows you to perform a search-and-replace operation on the line.

Format

.M [U] / search / replacement [/]

Parameter(s)

search

String.

replacement

String.

The .M command replaces the first occurrence of the search string with the replacement string. If there are multiple occurrences of the search string, specify the U option to make all changes on the line. If the replacement string is not specified, then the matched string will be deleted.

The following examples shows two uses of the .M command to edit a single command line. The first use is an example of making multiple replacements on a line using the U option. Without the U option, only the first occurrence of NAME would be changed to LAST-NAME. The second use is an example of a single replacement.

>.L1

001 LIST CUSTOMERS WITH NAME EQ SMITH NAME PHONE

 

>.MU/NAME/LAST-NAME/

LIST CUSTOMERS WITH LAST-NAME EQ SMITH LAST-NAME PHONE

 

>.M/SMITH/"SMITH"/

LIST CUSTOMERS WITH LAST-NAME EQ "SMITH" LAST-NAME PHONE

 

>

The search pattern must contain at least a single character. Remember that the search string need only consist of as many characters as will uniquely identify the text that you want to replace.

When deleting characters, the replacement pattern contains no characters. For example:

>.L1

001 LIST CUSTOMERS WITH NAME EQ SMITH SMITH NAME PHONE

 

>.M/SMITH//

LIST CUSTOMERS WITH NAME EQ SMITH NAME PHONE

 

>

Any nonnumeric character can be used as the delimiter in place of the slash (/). You might use a different delimiter, such as *, when either the search or replacement string contain a slash.

See Also

Using the TCL Stacker

Referencing Other Processes

Listing the Stack (.L)

Executing Previous Statements (.X)

Modifying Previous Statements

Editing the Stack (.E)

Choosing a Command to Modify

Appending Text (.A)

Storing a Series of Statements (.C)

Retrieving an Item (.R)

Deleting Statements from the Stack (.K)

Setting TCL Stacker Options (.O, .P, .U)