Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ gres(I) — UNIX 1BSD

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed (I)

GRES(I)  −  PWB/UNIX 6/12/75

NAME

gres − substitute for patterns throughout a file or files

SYNOPSIS

"gres" [ −g ] [ −v ] [ −f patternfile ] ... [ [ −e ] re1 re2 rhs ] ... [ file ] ... 

DESCRIPTION

Gres copies the input files (standard input default) to the standard output, performing substitutions for instances of one or more regular expressions.  The intention is to simulate a series of editor commands of the form: g/re1/s/re2/rhs/ on one or more files (see ed (I)).  A −e flag says that the next three arguments are to be used as an re1, re2, and rhs.  A −f flag says that the next argument is a patternfile, in which the first line is an re1, the second an re2, and the third an rhs.  Successive groups of three lines are interpreted similarly.  The −e and −f groups of arguments may be intermixed in any order.  The order of the simulated g commands is the order in which the program sees the pattern-triples; that is, the order in the command line, and within a −f group, the order in the pattern-file.  If no −e or −f flags are given, the first three arguments are used as re1, re2, and rhs.  When the first argument not in the scope of a flag is encountered, it and all succeeding arguments are taken as input files. For each line of input, an attempt is made to match the first re1.  If the attempt succeeds, an attempt is made to replace a match or matches of re2 by rhs.  Whether or not either attempt succeeds, the line as it exists after the action of the first "re1, re2," and rhs is used as input to the next "re1, re2," and rhs, etc.  Normally only the first match of an re2 in a line is replaced; but with a −g all instances of matches to re2 are replaced by rhs.  The −v flag causes the substitution to be attempted only on lines which do not contain matches of re1. 

FILES

SEE ALSO

ed (I)

DIAGNOSTICS

BUGS

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026