substitute for a pattern in a file 



gres pattern substitution [file ...]


gres reads input from each argument file and looks for all lines matching pattern. The pattern is an extended regular expression. See regexp for further information. For each input line matched, gres replaces all occurrences of matching strings with the replacement string substitution. It then writes its results to the standard output.

If you do not specify any files on the command line, gres reads the standard input.

As is the case for the substitution command in the ed text editor, the substitution string may contain the following shorthand notations:


The character & in the substitution string is replaced by the entire string that matched the regular expression pattern.


This notation is identical in meaning to &.


The number d must be a single digit between 1 and 9. If the pattern contains any portions enclosed by the () characters, the string \d is replaced by the text matched by the dth parenthesized portion of pattern. Parenthesized expressions are numbered by counting ( characters from the left.

To circumvent the special meaning of any of these characters, put \ in front of the special character. For example, to substitute a \ character, type \\.


This is a filter to switch political allegiance:

gres 'democrat(ic)?' republican


Possible exit status values are:


gres found at least one match for pattern and made the desired substitution.


gres found no matches for pattern.


Failure due to any of the following:

— command line had too few arguments
— invalid regular expression
— input file could not be opened


Windows Server 2012. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019.

This is really a simple subset of the sed command.


PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


ed, grep, sed


PTC MKS Toolkit 10.3 Documentation Build 39.