This is Stan Peters' original documentation for texrep. Reformatted only, words not changed except I added a few things - which I have clearly noted. I only included the section of the documentation I intended to emulate in this (Linux-tested) python version. I used the 1995 DOS version of this program often during the Palm handheld days. Reading ebooks on handhelds really started to take off during this period. The many different document formats often forced users to find ways to "fix" ebooks. Additional linefeeds to fix walls of text, excessive whitespace (or not enough)... all kinds of things needed tweaking. texrep (DOS, 1995, Stan Peters) delivered time and again - especially with its support for the ascii table (escape sequences) - which this script manages to emulate. If you ever need to change things in a text file and don't want to pull out sed and/or awk because syntax or maybe too many options... try this simple alternative out. As far as I'm concerned, it's legendary DOS software and I only hope I did it justice. - https://640kb.neocities.org ============================================================================= TEXREP, version 1.2. Copyright 1995 by Stan Peters Box 2028 Fairfield, IA. 52556 USING THE PROGRAM TEXREP has the simplest of syntax: texrep old:new stale:fresh myfile.doc This replaces all occurrences of old with new, and stale with fresh in the file myfile.doc. The output file will be myfile.do0. * (640kb: output will be myfile.NN.ext or myfile.NN if there is no extension) Up to 15 string pairs may be input at one time, each pair must contain one colon. If you wish to change a colon, or any other character, you can use decimal representation in the form \nnn. * (640kb: there is virtually no limit on string pairs in this updated version) Suppose you want to remove ctrl-z from a file: ctrl-z has a decimal value of 27, blank has a value of 32, so \26:\32 replaces the ctrl-z with a space. For example: texrep \58:; \13\10:\10 "\26: " myfile.doc replaces colon with semicolon, CRLF with LF, and change ctrl-z to space. * (640kb: Linux uses "\" as an escape character. Use quotes when pairing:) * (texrep "\13\10:\10" myfile.txt ) More advanced features are optional. The full usage is this: texrep [-w] [-i] s1:r1 [s2:r2] ... [@]infile [-ofileout] - There are two switches available: -w At times you may want to replace text only if it appears as a word. If so, add a -w before (EACH OF) the word pairs. -i Ignore case on the searches. The default is exact match, 'The' doesn't match 'the'. - There can be up to 15 replacement pairs, with a colon separating old:new text. You can use numeric (\nnn) as indicated above to signify a colon or other characters. If a digit follows a numeric use three digits for the numeric: if you wish to replace :7 with TEXT, enter \0587:TEXT. - Output file name need not be specified as TexRep will use the input filename, putting a digit in the right most position of the new filename. The -o option allows you to specify the output filename If the outfile filename exists, the low order digit in the filename extension will be advanced until a new filename is found.