summaryrefslogtreecommitdiff
path: root/src/rep.1
blob: 406dcc8aa6e1f90f9cf5f55917bf1d83bc6dc987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
.Dd September, 2002
.Dt REP 1
.Os Rep 2.3
.Sh NAME
.Nm rep
.Nd a regular expression search and replace language
.Sh SYNOPSIS
.Nm
.Op Fl ipq
.Op Fl z Ar buffsize
.Ar script
.Op Ar infile
.Op Ar outfile
.Nm 
.Fl f
.Op Fl bipq
.Op Fl z Ar buffsize
.Ar script
.Ar file
.Ar
.Sh DESCRIPTION
The 
.Nm
scripting language is a regular expression language used for fine grained, 
buffer based search and replace. It is not limited to lines. A full description
of what 
.Nm
is capable of is outside the scope of this document. 
.Pp
.Ar script 
is a text or compiled 
.Nm
script. For details see the language documentation that came along with the distribution.
.Pp
When used with the 
.Fl f 
argument 
.Nm 
replaces files in place. Otherwise it reads from 
.Ar infile
and writes to 
.Ar outfile
\&. If either infile or outfile are missing or are equal to a dash 
.Sq Li - 
, then rep processes 
.Em stdin
or 
.Em stdout
respectively.
.Sh OPTIONS
The options are as follows:
.Bl -tag -width Fl
.It Fl b
Backup files where replacements have occurred. The backup files have an
.Sq x_r
extension appended to their filename.
.It Fl i
Prompt for confirmation before each replacement.
.It Fl p
Only output replaced text. Can be used as a rudimentary parser.
.It Fl q
Supress status messages. Only errors will be sent to stderr.
.It Fl z
Set the replacement buffer size to 
.Ar buffsize .
This speeds up execution as regular expressions only have to act on a small
portion of the whole file at once. However the largest match will be limited to 
roughly 
.Ar buffsize 
, so use this option with care. The script loops over each buffer until no more
matches are found within it. Care is taken to overlap the buffers as much as 
possible to ensure that any match smaller than 
.Ar buffsize
can be matched.
.Sh NOTE
The
.Nm 
command uses 
.Xr getopt 3
to parse it's arguments, which allows it to accept 
the 
.Sq Li --
option which will stop processing of flag options at that point. This allows
the processing of files with names that begin with a dash
.Pq Sq - .
.Sh BUGS
When reading from 
.Em stdin
you must specify a buffer size.
.Sh SEE ALSO
.Xr repc 1 ,
.Xr rlib 3 ,
.Xr pcre 3
.Sh AUTHOR
.An Nate Nielsen Aq nielsen@memberwebs.com