Free Software for DOS >          

Text tools 3


This page:

sed – stream editor


grep – global regular expression print



 Also see the GNU Textutils.


Notes: Penta Text Tools can operate on one machine or over a network. ALTERTexRepGSAR are good choices for quick and dirty multiple file s/r. MiniTrue can run interactively, displaying context of matches in an internal viewer, prompt for replace, and includes basic and extended regular expression support. CHANGE can perform s/r with respect to presence of other strings on a line. sed is a power user's tool that supports regular expressions. Also see: awkPerl.

Penta Text Tools - Search, view, process strings in any text file.


[added 2000-09-10, updated 2004-08-20]

Based on Unix tools, these run on any DOS 2.0+ or emulator.

Notes: Interactive or batch S/R; extended regular expression support (cf. egrep). Operate on one machine or over a network. Small – easily run from diskette. Free for non-profit and non-government users.

Author: Anunga Muhummud / Intelligence Services, Australia (2002).

2002-09-25: v2.4.

Download (421K).

Penta Text Tools Online Reference Guide.

MiniTrue - Multiple file S/R with regular expression support.

* * * * *

[added 1996, updated 2010-03-30]

"MiniTrue synthesizes the functionality of such stalwarts as sed, more/less and grep while offering complete interactivity and a straightforward syntax." This flexible text search/replace utility is great if you need to search for, or replace, an instance of text across several files. MT incorporates a full screen file viewer which displays the context of matching text within a document.


Authors: Andrew B. Pipkin, Jason Hood.

Download 3 available versions from FSFD:

v2.0.2b. 16- and 32-bit DOS versions. Andrew B. Pipkin (1999)
v 2.0.2 alpha #3:fixes LFN issues and large file handling for the 32-bit DOS version. Jason Hood (2009)
v2.0.2 alpha #3,Win32 console port. Jason Hood (2009)


TexRep - Easy, multi-string text search and replace tool.


[added 1999-04-04, updated 2004-06-27]

One of the more comprehensible S/R tools listed here. Includes an easy command syntax, and the help screen can display a table of those hard-to-remember decimal code equivalents for special characters. Up to 15 string pairs may be input at one time. Can accept as input a file list, won't overwrite original files.

condensed SYNTAX:
texrep [-w] [-i]  s1:r1  [s2:r2] ... [@]infile  [-ofileout]
        -w  At times you may want to replace text only if it appears
            as a word. If so, add a -w before the word pairs.
        -i  Ignore case on the searches.
        -o option allows you to specify the output filename, with two variants:
           -ooutfilex.nam  names the output file in full
           use a period following the o to use the file
                           name, changing the extension to xxx (any set of
                           one to three characters.

Limitations: No regular expression support. Can't take input from redirection.

Author: Stan Peters (1995). Suggested by Dan Dunfee.

1995-07-25: v1.2.

Download (16K).

Alter - Small and fast global search and replace tool.

* * * *

Comments from a user:
My all-time favourite search-and-replace is Rob Flor's wonderful ALTER...Exceedingly fast, can accept wildcards _and_ make back ups, can be used as a filter, can mix plain strings with ASCII codes. Only thing extra I'd like is the ability to handle multiple search/replace strings at one time.

Disadvantages: No regular expression support. No "case insensitive" option. Doesn't allow multiple s/r requests. Can't insert an ASCII code for literal quotation mark within a string?

ALTER "find text" "Replace text"<FileName >OutFile
ALTER FileName.ext "find text" "Replace text"
Wildcards may be used in filename.  Tally is output to screen.
TYPE Filename |ALTER "find text" "Replace text">OutFile
Comma delimited ASCII codes may be mixed with quote delimited text

 0 if no changes made.
 1 if changes made.
 2 if file not found.
 3 if argument quote mismatch.
Total changes put in Env. Variable %CH%
ALTER -QFileName.ext arg arg  for quiet mode

Author: Rob Flor (1992). Suggested by Robert Bull.

1992-05-05: v0.06i beta.

Download (8K).

GSAR (General Search And Replace) - Multi-file, text or binary, search and replace.


[added 1998-07-04, updated 2005-08-22]

A simple search and replace tool that's (usually) easy on the fingers.

Usage: gsar [options] [infile(s)] [outfile]
-s<string> Search string
-r[string] Replace string. Use '-r' to delete the search string from the file
-i         Ignore case difference when comparing strings
-B         just display search & replace Buffers
-f         Force overwrite of an existing output file
-o         Overwrite the existing input file
-c[n]      show textual Context of match, 'n' is number of bytes in context
-x[n]      show context as a heX dump, 'n' is number of bytes in context
-b         display Byte offsets of matches in file
-l         only List filespec and number of matches (default)
-h         suppress display of filespec when displaying context or offsets
-du        convert a DOS ASCII file to UNIX (strips carriage return)
-ud        convert a UNIX ASCII file to DOS (adds carriage return)
-F         'Filter' mode, input from stdin and eventual output to stdout
Ctrl characters may be entered by using a ':' in the string followed by the
ASCII value of the character. The value is entered using ':' followed by three
decimal digits or ':x' followed by two hex numbers. To enter ':' use '::'
Notes: No regular expression support. Download packages include C source code. Released under GNU General Public License.

Authors: Tormod Tjaberg and Hans Peter Verne, Norway (1996, 2004).

Win32 console


CHANGE - Contextual multi-file search and replace tool.


[added 2002-11-15]

Change is an easy to use, basic search and replace tool that lacks regular expression support but does excel as an s/r tool with contextual awareness: you can replace strings based on the presence or absence of other strings which occur on a line (e.g., "replace apple with orange only if peach also occurs in line of text"). This capability can be finely tuned using Boolean operators ("replace apple with orange only if peach AND banana occur on same line"). More complex nesting of Boolean statements is supported. Best of all, Change's syntax is easy to comprehend.

Other features: Disadvantages:

Author: Bruce Guthrie (2002).

2002-08-10: v0208.

Download CHAN0208.ZIP (93K).

More in these pages from Bruce Guthrie.

GSR (Global Search Replace) - 32-bit interactive or c-line mode multi-file search and replace tool.

[added 1999-05-03]

Started with no parameters, GSR presents a dBase-like form to be filled in with filespec (wildcards permitted), text to search for, text to replace with, whether search will be case sensitive, whether replacements will be performed with or without user's approval of each one, and whether to process subdirectories. Or, GSR can be started with all parameters entered into the command-line. Compiled Clipper app, with source. Released under GNU general Public License.

Author: Phil Barnett / The Oasis (1999). Suggested by Howard Schwartz.

1999-01-09: v1.84.

Download (223K).

sed – stream editor

Text search & replace (and more) using regular expressions, from the Unix world.

sed, a popular and powerful tool, is frequently used for text search and replace. It is also useful as a versatile filter / formatter. Requires facility with regular expressions. Three versions are listed here.

For more about sed, and seds, go to Eric Pement's sed . . . the stream editor.

GNU sed - 32-bit port of the GNU OS version.


[added 1998-09-02, updated 2005-08-03]

32-bit DJGPP build – requires 80386+ and a DOS Protected Mode Interface (CWSDPMI or other). Documentation is directed toward experienced users.

Author: Port by Juan Manuel Guerrero, Germany (2005).

2005-04-01: v4.1.4.

Binaries, manual
Docs: html/dvi/ps/pdf

U-SEDIT - A sed with clear documentation, 16-bit port from Unix.


[added 1998-09-22]

Mere mortals may want to look at this older sed version with approachable documentation. A 16-bit offshoot of GNU sed, it runs on DOS 2.0+.

Author: Mike Arst (1990). Suggested by Robert Bull.


EXE, docs
Updated docs

Download both

HHsed (sed15) - Another real mode sed.

[updated 2004-10-29]

From the docs, a few distinctive features:

This version otherwise appears to be equivalent to the UNIX version on the Sun4 computer... anything that sed did on that system, this version of sed will do the same on either a Sun4 or a PC under DOS.

Authors: Eric S. Raymond, David P. Kirschbaum, Howard L. Helman (1991).

1991-10-01: v1.5.

EXE, manual
Source, history


TSP - Interactive text search program.


[added 1998-07-14, updated 2000-04-30]

TSP is an interactive text searcher which uses an internal viewer to display matching text within the context of adjacent lines (cf. MiniTrue). As you step through matches in each file you can write selected matching lines to a file or send them to a printer. During an interactive run you can also load a file with matching text into your favorite editor (default is Brief, or define another editor in an env. var.). TSP can run in a non-interactive mode with automatic writing of matching lines to a file or the printer. Handled a 1.25 MB test file with ease.

TSP [@][drive:][path]filename target_string [/C] [/AW] [/AP] [/AE] [/1] [/B]
     [/S] [/X:[@]file.ext] [/L:outfile.ext] [/A:attributes]

  [drive:][path]filename   File specification including wildcards.
  @[drive:][path]filename  Search list of file specification(s) in filename.
  target_string            String to be searched for.
  /C                       Use case-sensitive search, by default ignores case.
  /AW                      Automatically write results to a file.
  /AP                      Automatically send results to the printer.
  /AE                      Automatically edit files when a match is found.
  /1                       Find first occurrence of target_string in each file.
  /B                       Write results to Brief .APX file in First-Only mode.
  /S                       Searches subdirectories under specified directory.
  /X:[@]file.ext           Excludes subdirectories from subdirectory search.
  /L:outfile.ext           Name of output file. Default name is FOUND.TSP.
                           The extension is always .APX when /B switch is used.
  /A:attributes            Also searches files with the specified attributes.
                           Attributes can be H (hidden) and/or S (system).

Limitation: No regular expression support.

Author: Paul Bosselaers (2000). Suggested by Marianna Van Erp.

2000-04-17: v2.21.

Download (28K).

grep – global regular expression print

 Text search using regular expressions, from the Unix world.

 Also see dg (data-grepper) – Search for complete records based on search phrase.

GNU grep, egrep, fgrep - Search for text; basic and extended regular expression support.


[added 1998-07-23, updated 2005-05-27]

One of many available UNIX-derived greps for DOS, GNU's combines the functions of:

Search using basic regular expressions
Search using extended regular expressions
Search using fixed strings

Two different packages are available: A 16-bit version, with a single EXE (command line options set its function); and a 32-bit version with grep, egrep, and fgrep binaries that are identical except for filename.

Other differences between versions: The older 16-bit grep doesn't have a "recurse subdirectories" option, but the 32-bit version does. The 32-bit version is a DJGPP v2 build, requiring 80386+ and a DOS Protected Mode Interface (CWSDPMI or other).

Authors: 16-bit port by Stephen McConnell (1995); 32-bit port by Andrew Cottrell (2003).



EXE, manual
Docs: dvi/ps

Fast GREP (FGREP, FGREP386) - Find files containing search string.

* * *

Fast GREP, like many similar grep utilities for DOS, finds files in which a given string of text occurs. There are many free grep utilities available, and some support regular expressions and mimic their UNIX counterparts well. Not all are simple to comprehend, however: Fast GREP is distinct for its small size, speed, option suite, and relative ease of use. It's only 8K and is optimized for fast operation. Its principle drawback is lack of regular expression support. Runs on DOS 3.0+. No Win9x LFN support, will not handle extremely long paths.

Included in package:
For 8/16 bit CPU
For 32-bit CPU
Build a character frequency table

Use Fast GREP's GREP386.COM with 80386+ CPUs – it's faster than GREP.COM. Fast GREP has a built-in character frequency table, designed to be a good fit with program code, but not necessarily best for all text content. The BUILDIT util can be used to create a custom table, adapted to user needs.

USAGE: fgrep [-Zv] [options] target {[@]file...}

switches: (edited for formatting)
-a ANSI mode).......................-r recurs. search (dirs/subdirs)
-b binary search....................-R recurs. search (subdirs)
-B case insensitive binary search...-s suppress **File header lines
-c case sensitive...................-t display found text only
-e return errorlevel only...........-v reVerse (negative) search
-f display **File header only.......-w whitespace not significant
-g[name] get frequency table........-x no logo
-i#[,#] define input search field...-Za echo command line to stdout
-j left justify output..............-Zb filter "bell" characters
-l line numbers.....................-Zd display current search dir
-m M-soft(R) output format..........-Zl send logo to stdout
-M M-soft(R) output format w/ path..-Zv ignore FGREP= env variable
-o# set max output length, 0-50000..-0 display no text
-p pause on full screen.............-1 disp. 1st matching line only
-@ generate ONLY list of matching file names
-? display this information using stdout
@file indicates a text file containing a file list

Author: Christopher J. Dunford (1997).

1997-06-04: v1.84.

Download (29K).

XGREP - Tiny text finder with regular expression support.

* * * *

XGREP is yet another text finding utility. XGREP displays the lines in a file that contain a particular word, phrase, or pattern; can count those lines in which a particular pattern occurs; or can generate a list of files that refer to a given topic. Like a true grep program, XGREP supports "regular expression" searches. That is, one can perform flexible searches for text strings meeting a range of criteria (e.g., find text matching four consecutive numbers, restricted to digits 1-7). What separates XGREP from the freeware competition is its small size (3K) and the author's good documentation of regular expression syntax. One .COM file, compiled from 80x86 ASM source.

Usage: XGREP [-chlnsvyorx] expression [file ...]
-c Line count only.. -r Recursively search subdirectories
-h No file names.... -s Silent about inaccessible files
-l File names only.. -v Non-matching lines
-n Number lines..... -x No magic: all operators need \
-o Errors to stdout. -y Case-insensitive match
^ .. start of line...... repeat:. * ..... 0 or more times
$ .. end of line................. + ......1 or more times
.... wildcard.................... ? ......0 or 1 times
[] . character class............. \{m\}.. m times
[^]. inverse class............... \{m,\}..m or more times
\ .. quote next character........ \{m,u\}.m to u times
:a alpha...:c cntrl...:d digit...:g graph
:l lower...:n alnum...:p punct...:s space
:t print...:u upper...:x xdigit..:z ascii

Author: Robert Nordier, South Africa (1994).

1994-06-17: v1.03.

Download (13K).

AGREP - Fast grep-like util with approximate pattern matching capability.


[added 1998-07-03, updated 2005-12-09]

This program is intended for users familiar with regular expression syntax, but it has OK docs, good help screens, and a sufficient variety of useful examples. Copyrighted, free only for private, non-commercial use. From the docs:

AGREP is a powerful tool for fast searching a file or many files for a string or regular expression, with approximate matching capabilities and user-definable records...AGREP is similar to egrep (or grep or fgrep), but it is much more general and usually faster...It also supports many kinds of queries including arbitrary wild cards, sets of patterns, and in general, regular expressions. It supports most of the options supported by the grep family plus several more (but it is not 100% compatible with grep).
AGREP [-#cdehi[a|#]klnprstvwxyABDGIRS] [-f patternfile] [-H dir] pattern [files
-#  find matches with at most # errors     -A  always output file names
-c  output the number of matched records   -B  find best match to the pattern
-d  define record delimiter                -Dk deletion cost is k
-e  for use when pattern begins with -     -G  output the files with a match
-f  name of file containing patterns       -Ik insertion cost is k
-h  do not display file names              -Sk substitution cost is k
-i  case-insensitive search; ISO <> ASCII  -ia ISO chars mapped to lower ASCII
-i# digits-match-digits, letters-letters   -i0 case-sensitive search
-k  treat pattern literally - no meta-characters
-l  output the names of files that contain a match
-n  output record prefixed by line number
-p  supersequence search                   -CP 850|437 set codepage
-r  recurse subdirectories (UNIX style)    -s silent
-t  for use when delimiter is at the end of records
-v  output those records without matches   -V[012345V] version / verbose more
-w  pattern has to match as a word: "win" will not match "wind"
-x  pattern must match a whole line
-y  suppresses the prompt when used with -B option
@listfile  use the file names in listfile
\z          turns off any special meaning of character z (\# matches #)
^           begin-of-line symbol
$           end-of-line symbol
.           matches any single character (except newline)
#           matches any number > 0 of arbitrary characters
(a)*        matches zero or more instances of preceding token a (Kleene closure)
a(a)*       matches one or more instances of preceding token a
            (Use this as replacement for (a)+ which is not implemented yet.)
[b-dq-tz]   matches characters b c d q r s t z
[^b-diq-tz] matches all characters EXCEPT b c d i q r s t z
ab|cd       matches "ab" OR "cd"
<abcd>      matches exactly, no errors allowed in string "abcd"
            (overrides the -1 option)
cat,dog     matches records having "cat" OR "dog"
cat;dog     matches records having "cat" AND "dog"
Four compilations are available. The packages are substantial, and the EXEs are large (about 300K). All versions are 32-bit, require 80386+.

Authors: Sun Wu and Udi Manber, et al. DOS port by Tom Gries, Germany (1998).

DOS, OS/2, DOS box
Win32 only

DOS, OS/2, DOS box
All DOS & OS/2 EXEs, support files, source
Win32 EXE only
Win32, with source

Get more info at Tom Gries's AGREP page.


KLine - Delete lines of text containing search string.

* * *

KLine deletes entire lines which contain a search string. Accepts wildcards and creates a backup of original file. Outputs the number of lines killed per file. Case sensitive/insensitive options.

Limitation: KLine will truncate lines longer than 255 characters.

Usage: KLine text_file(s) "offending string" [/c (case sensitive)]

Author: David Daniel Anderson / Reign Ware (1994).

1994-09-02: v1.01.

Download (13K).

YANK - Replace or delete lines of text containing search string.

* * * *

[added 1998-04-19, updated 2000-03-02, links updated 2010-07-26]

Like KLine, this program can be used to strip out entire lines containing a search string, but it also offers the option of replacing the line with another string, or an image file's content, rather than deleting it. Search and replace strings can be any combination of literals and ASCII codes. Other differences from KLine: 1) YANK handles longer lines; 2) does not create a backup file; 4) "can read from another file both the search and replace string specifications or replacement text image (65,534 char. max; search string limit 4,095 char.)."

Limitations: Unlike KLine, YANK doesn't output number of changes made per file. Works fine on my MS-DOS machine – but can't get it to work properly under OpenDOS.

YANK [/i] filespec "[srchstrng][^[x]chr,][...]" ["[replstrng][^[x]chr,][...]"]
YANK [/i] filespec @scriptfile or YANK [/i] filespec "srchspec" @imagefile insensitive

Author: Clay Ruth (1996, 2000). Suggested by Marianna Van Erp.

2000-01-14: v1.3, part of Clay's Utilities for MS-DOS.

Download (398K).

Go to Clay's Utilities for DOS Batch Processes for upgrades of some other utils in the package, Windows version, info, license agreement & more.


Text file compare programs are frequently used by programmers for version maintenance – but they can also be used by us common folk to compare two versions of an ascii document (e.g., different versions of those autoexec.* files that accumulate in your root directory, file lists, etc.). The programs below may use different "difference" algorithms – each with unique strengths / limitations. Not usually a major issue for simple uses, but you may wish to try them all to determine which suits your needs and style best. The programs listed below may not be the best picks for programming needs.

Also see: GNU Diffutils (diff) - File difference package.

Double Lister - Dual window text comparer.


[added 12-15-98, updated 2004-08-20]

From the docs:
...displays two files simultaneously in separate windows. These can be scrolled individually, or locked together, useful to locate differences between similar files. Options: Search for text string, split windows horizontally or vertically, change window size and tab spacing, display line ends, 7-bit mode, hex mode with offsets and alignment.

Author: Steven S. Bates (1989). Suggested by Robert Bull.

1989-05-08: v1.03.


Visual Compare - Feature-rich file comparer.

* * * * *

A favorite for general use because of the flexible display options. Interactive and command line modes; possesses an internal viewer with scrolling capability; by default it colorizes new/old/changed text which makes for easy comprehension of differences. Split window (horiz. or vertical), dual file display option. Flexible output options. Understands UNIX formatted text.

"The maximum allowed line length in file one and file two is 2048 characters. The maximum number of lines that file one and file two each can contain is 16368. The maximum number of lines that the composite file can contain is 16368."

Difference algorithm used: "linear space refinement of the basic O(ND) difference algorithm."

Command line usage: VCOMP fileone filetwo [options]
/B...Monochrome display.
/Tn...Tab width. Range is 2-64. Default is 8.
/25...Display 25 lines if you have either an EGA or a VGA.
/43...Display 43 lines if you have an EGA.
/50...Display 50 lines if you have a VGA.
/S[-].Write edit script to standard output.
/C...Write composite file to standard output.
/D...Write difference file to standard output.
/En...Maximum edit distance. Range is 0-32736. Default is 32736.
/I...Ignore leading space and tab characters.
/K...Consider upper-case and lower-case letters equivalent.
/Z...Consider all characters significant.

Author: John R. Whitney (1993).

1993-12-19: v1.54.

Download (38K).

@COMPARE - Text file comparer for very large files.

* * *

[updated 2005-12-09]

(aka "ATCOMPARE", "ACOMPARE"). Comprehensible ouput to screen is color coded – but you can't scroll back through output as in VCOMP. Easily digestible report-to-text file output with side-by-side comparisons (unfortunately broken word fragments can result from the program's wrapping of text when generating side-by-side comparisons).

Usage: @Compare [options] [<filename1> [<filename2>]]
where [options] begins with / or -, and is
a combination of the following:
P -directs output to the printer
F -directs output to a file
M -suppresses colors for monochrome monitors
T -suppresses the title header
H -suppresses highlighting in unequal lines
A -replaces graphics characters with standard Ascii codes
R -prints a report of discrepancies by field to a file
C -disables breaks after every screenful of output
L -allows for long and
E -extra long searches; not usually necessary
B -suppress direct video writes; use BIOS instead
Q -quits

Author: Brian C. Madsen (1994-98). Suggested by Marianna Van Erp.

1999-05-13: v1.8. Bug fix for fast Pentiums.

Download (23K).

jDif - Fast file difference utility.


[updated 2005-12-09]

Don't have much experience with this one. Fast, color-coded output to screen, or send results to report file.

Syntax: jdif oldfile newfile [options]

/a...370 Assembler (columns 1 to 72)
/c...COBOL (columns 7 to 72)
/f...DOS FC style output
/h...Help (this is it)
/r...output Report
/ not buffer output

"Private persons are hereby licensed to use the software at home for non-commercial purposes at no charge."

Author: Jonathan Rosenne / QSM Programming Ltd., Israel (1996). Suggested by Marianna Van Erp.

1996-05-18: v1.0.

Download (36K).

jDif page.

Fintrsct (File INTeRSeCTion) - Compare 2 files; outputs shared / unique lines to 3 report files.


[added 1998-07-05, updated 2006-03-14]

Fintrsct takes a different approach to the task of file comparing. It compares two (smaller) files and outputs three files: one file containing lines unique to file 1; a second file containing lines unique to file 2; and a third file containing paired, shared lines. Lines are numbered to allow easy location in original files. The order of lines in the input files is not relevant, and comparisons are case insensitive. Useful for comparing different versions of win.ini, autoexec.bat, etc. Also useful for comparing updated file lists (e.g., easily determine "what's new"). Two version included: 16-bit DOS and 32-bit Windows.

Remarks: This tool acts similar to line uniqifiers, but doesn't require the manual merge of the two text files and post-merge sorting. The DOS version handles smaller files. I tested two 200K files (about 20,000 one-word lines each) and the program locked my machine. I then tested two 100K files (about 10,000 one-word lines, with one shared line) and it worked, but took about two minutes to process on a P-60. Win32 version untested.

USAGE: fintrsct file1 file2

Creates :
unique1 - lines unique to file1
unique2 - lines unique to file2
common  - lines common to file1 and file2

Author: Paul Trout (1996). Suggested by Marianna Van Erp.

1996-12-07 release.

Download (24K).

Go to Top | Front Page ]

©1994-2022 Rich Green.
©2004-2022, Steve Adelwitz (Short.Stop).