5.3. Why does my DOS version of sed process a file part-way through and then quit?
First, look for errors in the script. Have you used the -n switch
without telling sed to print anything to the console? Have you read
the docs to your version of sed to see if it has a syntax you may
have misused? (Look for an N or H command that gathers too much.)
Next, if you are sure your sed script is valid, a probable cause is
an end-of-file marker embedded in the file. An EOF marker (SUB) is
a Control-Z character, with the value of 1A hex (26 decimal). As
soon as any DOS version of sed encounters a Ctrl-Z character, sed
To locate the EOF character, use Vern Buerg's shareware file viewer
LIST.COM <https://www.buerg.com/list.html>. In text mode, look for a
right-arrow symbol; in hex mode (Alt-H), look for a 1A code. With
Unix utilities ported to DOS, use 'od' (octal dump) to display
hexcodes in your file, and then use sed to locate the offending
od -txC badfile.txt | sed -n "/ 1a /p; / 1a$/p"
Then edit the input file to remove the offending character(s).
If you would rather NOT edit the input file, there is still a fix.
It requires the DJGPP 32-bit port of 'tr', the Unix translate
program (v1.22 or higher). GNU od and tr are currently at v2.0 (for
DOS); they are packaged with the GNU text utilities, available at
It is important to get the DJGPP version of 'tr' because other
versions ported to DOS will stop processing when they encounter the
EOF character. Use the -d (delete) command:
tr -d \32 < badfile.txt | sed -f myscript.sed