Text Utils for DOS:
Text Search/ Search and Replace.

Back to Front Page

global menu:



TEXT SEARCH and REPLACE

Notes: ALTER, TexRep, and GSAR 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: Awk, Perl.
09-10-00: Need to add: PentaTextTools: Interactive or batch S/R; extended regular expression support (cf. EGREP). isgtt18x.zip (370K) Author: Anunga Muhummud. (2000)


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

* * * * * [added 1996 updated 12-23-99]

"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. Features:

Author: Andrew B. Pipkin. Home Page. (1999)

12-23-99: new in v2.0.2b (11-99): bugfixes. v2.00 is a complete rewrite with significant additions (e.g., support for extended reg. expressions) and modifications (syntax changes): see the docs. MT is now available in both 16 and 32-bit versions. A Linux binary is also available as is source (see home page). Now GPL'd.

download mtr202b.zip (192K, incl. 16 and 32-bit ver.)

Earlier versions: download mintr151.zip (66K)


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

unrated [added 04-04-99]

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.

Limitations:

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

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
           -o.xxx          use a period following the o to use the file 
                           name, changing the extension to xxx (any set of 
                           one to three characters.

download texrep12.zip (16K)


3. 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." Author: Rob Flor (1992). Suggested by R. Bull.

Syntax: ALTER filepec "search text" "replace text">outfile
Example:
DIR |ALTER "." "" >outfile

Features:

Disadvantages

download alter.zip (8K)


4. GSAR- Multi-file search and replace.

unrated [added 7-4-98]

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

Notes:

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 '::'

download gsar110.zip (50K, source included)


5. Change- Contextual multi-file search and replace tool.

unrated [added 7-4-98]

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 Wayne Software (1999).

11-23-99: v911 released 11-99.

Get chang911.zip (100K) from Download Page.


6a. sed (GNU)- Text search & replace (and more) using regular expressions.

unrated [added 9-2-98 updated 06-11-00]

Sed (Stream EDitor) is a popular and powerful tool from the Unix world frequently used for text search and replace; also useful as a versatile filter/ formatting tool. Requires facility with regular expressions. Documentation is directed toward experienced users.

The DJGPP package listed here includes two executables: sed.exe (uses DJGPP regexp library, fast) and gsed.exe (uses GNU regexp library which adheres to latest POSIX standards, but slower than sed.exe). Require a 386+ and a DPMI provider (cwsdpmi.exe). (2000)

06-11-00: 05-00 build of v3.02 available.

download sed302b.zip (107K, sources zipped separately)

6b. U-SEDIT- sed text processing tool with good documentation.

unrated [added 9-22-98]

Mere mortals may want to look at an older sed version which has approachable documentation. Author: Mike Arst (1990); Suggested by Robert Bull.

download u-sedit2.zip (76K)
and docs-only update: u-sedit3.zip (64K, 1992)

Other sed resources:

TEXT SEARCH, GREP TOOLS


1. FGREP386- Find files containing search string.

* * *

FGREP386, 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. I use FGREP386 because of its small size, speed, option suite, and relative ease of use. It's only 8K and is optimized for fast operation (a 386 version is included). Its principle drawback is lack of regular expression support. Win9x: No LFN support/ will not handle extremely long paths. Author: Christopher J. Dunford. (1997)

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

download fgrep184.zip (34K)


2. 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. Author: Robert Nordier (1994).

Usage: XGREP [-chlnsvyorx] expression [file ...]
Options:
-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
Syntax:
^ .. 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
Classes:
:a alpha...:c cntrl...:d digit...:g graph
:l lower...:n alnum...:p punct...:s space
:t print...:u upper...:x xdigit..:z ascii

download xgrep103.zip (13K)


3. grep (GNU)- Search for text; basic and extended regular expression support.

unrated [added 7-23-98 updated 01-26-00]

One of many available UNIX-derived greps ("global regular expression print") for DOS. This 32-bit DJGPP port combines the functions of the traditional fgrep (search using fixed strings), grep (search using basic regular expressions), and egrep (search using extended regular expressions). Older GREPs didn't have a "recurse subdirectories" option but v2.3+ does (-r, but I've had no success with it [pre-compiled binary]). Package includes grep, egrep, and fgrep binaries (identical except for filename). Requires a DPMI-provider (cwsdpmi.exe), and a 386+ PC. Port by Eli Zaretskii (2000)

01-26-00: v2.4 (1-00) available:"This release includes several new features: new command-line option for searching directories recursively, the GREP_OPTIONS environment variable, and some others. See the file NEWS for the full list. "

download grep24b.zip (87K)

Older 16-bit port (v2.0):
ftp://gatekeeper.dec.com/pub/micro/pc/simtelnet/gnu/gnuish/dos_only/grep20ax.zip (54K)


4. AGREP- Fast GREP-like util with approximate pattern matching capability.

unrated [added 7-3-98]

(Intended for users familiar with regular expression syntax, but this package has ok docs; good help screens, and a sufficient variety of useful examples.)

"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)." Needs 386+ PC. Authors: Manber/Wu/Gries et al.; EMX DOS port by T. Gries (1998)

Usage:
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 
METASYMBOLS:
\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"

Two versions are available for DOS:

Download:

agrepdos.zip (agrepdos, 147K) or
agrep.zip (agrep, 249K)

links adjusted 02-27-00


4. dg -Search for complete records based on search phrase.

See extended description.


5. TSP- Interactive text search program.

unrated [added 7-14-98 updated 04-30-00]

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. Usage:

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).

Limitations: No regular expression support.

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

download tsp221.zip (25K)


LINE KILL, LINE REPLACE


1. YANK- Replace or delete lines in text file(s) containing search string.
2. KLine- Delete lines in text file(s) containing search string.

1. YANK: * * * * [added 4-19-98 updated 03-02-00]. 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 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. Part of the CUTPAK package. Author: Clay Ruth (1996, 2000). Sugg. by M. Van Erp.

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

03-02-00: Package now at v13; Yank not changed.

2. KLine: * * * 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. Limitations: KLine will truncate lines longer than 255 characters. Author: D. D. Anderson/ Reign Ware (1994).

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

[ Go to Top | Front Page ]

© 1994-2001. Rich Green