I'm looking for a really simple commandline search and replace tool, which can be run non-interactively and told to find and replace a string in a text file.
Any suggestions?
Any suggestions?








rjbull: Eek, using 16bit dos executables under win32? Why haven't you searched for a replacement tool?
- DOS programs have a disadvantage running under windows since they need some virtualization... and won't run at all under 64bit windows (outside of full emulation, like dosbox). I still use plenty of console applications, but it's been several years since I've used anything 16bit. Seems like the 32bit version is DJGPP, no wonder it's quirky on NT based operating systems then 

gsar (General Search And Replace) is a utility for searching for and --- optionally --- replacing strings in both text and binary files. The search and replace strings can contain all kinds of characters (0--255), i.e. Ctrl characters and extended ASCII as well.
The algorithm used is a variation of the Boyer-Moore search algorithm, modified to search binary files. As a result of this, gsar is blindingly fast.
Opposed to line oriented search programs (like grep(1)), gsar will find all matches on a line. Actually, gsar doesn't know anything about lines at all, all files and strings are treated as binary.
Gsar can search one or several files for a string and report the occurrences. Gsar can read one file, search for a string, replace it with some other string, and create a new file containing the changes. Gsar can perform a search and replace in multiple files, overwriting the originals. Finally, gsar can work as a filter, reading from standard input and writing to standard output.



I have used this before and found it more than adequate.
GSAR: GSAR Project Page





But if you want an app that provides an easy-to-use GUI for building & saving sets of search-replace operations -- which you can then call from a command-line -- consider BK ReplaceEm.
So I went with SED. It's case-sensitive, but that was OK for what I wanted.


http://www.gnu.org/software/grep/>
But if you want an app that provides an easy-to-use GUI for building & saving sets of search-replace operations -- which you can then call from a command-line -- consider BK ReplaceEm.
This 32-bit Windows freeware application hasn't been supported or distributed by its developer Bill Klein (BK) for a number of years. But it was once considered among the very best search-n-replace apps (free or not). And I think it still deserves such consideration.
For a rather complicated example of the very sort which originally inspired BK to create his application, see: <http://www.ccp14.ac.uk/ccp14admin/bkreplacem/index.html




I've written just such a tool for Windows.Thanks for telling us about this. Does the Options file allow one to enter multiple search-and-replace pairs?
It has the following features:
Easy to use in Windows batch files
Supports Windows and Unix line endings
Unicode support
Accepts multiple search/replace arguments
Original address: https://www.donationcoder.com/forum/index.php?topic=15920.0