gres

substitute for a pattern in a file 

Command


SYNOPSIS

gres pattern substitution [file ...]


DESCRIPTION

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.

\0 

This notation is identical in meaning to &.

\d 

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 \\.


EXAMPLES

This is a filter to switch political allegiance:

gres 'democrat(ic)?' republican

DIAGNOSTICS

Possible exit status values are:

0 

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

1 

gres found no matches for pattern.

2 

Failure due to any of the following:

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


PORTABILITY

Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.

This is really a simple subset of the sed command.


AVAILABILITY

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


SEE ALSO

Commands:
ed, grep, sed

Miscellaneous:
regexp


PTC MKS Toolkit 10.1 Documentation Build 15.