"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 Here is a feature comparison list between the four major UNIX string
2 replacement programs that have source code available for them:
3
4 MySQL: http://dev.mysql.com/doc/mysql/en/replace_utility.html
5 sed: ftp://ftp.gnu.org/pub/gnu/sed/
6 rpl: http://www.laffeycomputer.com/rpl.html
7 replace: http://replace.richardlloyd.org.uk/
8
9 Feature MySQL sed rpl replace
10 -----------------------------------------------------------------------
11 Freely modifiable/re-distributable Yes Yes No Yes
12 Verbose mode Yes No Yes Yes
13 Interactive prompting No No Yes Yes
14 Fake mode (show but don't do it) No No Yes Yes
15 Match new string case against old text No No No Yes
16 Case-insensitive old string matching No No Yes Yes
17 Word matching No No Yes Yes
18 Multiple replacement pairs Yes Yes No Yes
19 Unlimited string lengths Yes Yes No Yes
20 Can replace blank lines with new string No Yes No Yes
21 Replace using stdin/stdout Yes Yes No Yes
22 Auto-detect binary files No No No Yes
23 Binary/hex string replacement No No No Yes
24 Original file backup No Yes No Yes
25 Clean up temp files on CTRL-C No No No Yes
26 String padding No No No Yes
27 Retain timestamp of original No No Yes Yes
28 Retain owner/group/perms of original No No Yes Yes
29 Directory recursion No No Yes Yes
30 Suffix match during recursion No No Yes Yes
31 -----------------------------------------------------------------------
32 Final score 5/20 6/20 9/20 20/20
33
34 Note that replacing strings in files with an optional backup (-i flag) is
35 a new and most welcome feature in GNU sed 4.X or later, but sed's syntax
36 sadly remains extremely user-hostile even in the latest GNU sed. MySQL's
37 /usr/bin/replace (yes, it name-clashes with mine and I've told them that)
38 is now the worst of the well-known replacement programs because it has very
39 little to offer that can't be scripted with sed.
40
41 rpl is a good alternative to sed for command-line use, though there are
42 some drawbacks to it. The fact you're not allow to modify it and re-distribute
43 the modified version is slightly disappointing (MySQL, sed and replace allow
44 this, so why not rpl?) and the failure to allow the original file to be backed
45 up before replacing strings in them is risking users' files unnecessarily
46 (though this is promised as a feature in a future release). However, the two
47 major omissions I can see from rpl (and both are supported in sed and replace)
48 are the lack of multiple string replacement pairs and, even worse, the failure
49 to support stdin/stdout for replacements, which severely limits its use in
50 shell scripting.
51
52 replace has some major advantages over both sed and rpl, particularly the
53 auto-detection of binaries and the subsequent correct handling of replacements
54 within binary files. This is a noticeable flaw in rpl because it has the
55 recursive capability to destroy your binary files if you specify -r and supply
56 an old string with a different length to the new string. Somewhat surprisingly,
57 this destructive timebomb isn't mentioned anywhere in the rpl documentation
58 or source code !
59
60 The other big advantage of replace is its ability to retain the case of the
61 original text being replaced (not the old string - the actual file contents)
62 when replacing it with a new string. This is the reason I wrote replace in
63 the first place - it's natural to keep the case (text can be in upper case
64 and mixed case you know !) and a replace program that doesn't allow this is
65 somewhat lacking, IMHO.
66
67 The feature list table above was correct as of Thursday 7th October 2004.
68 If you wish to make corrections to it, please e-mail
69 replace@richardlloyd.org.uk and I'll appropriately adjust it.