Help with sed Syntax

Grace Quilico quilico at CECOM-2.arpa
Wed Oct 22 03:26:57 AEST 1986


I'm have been trying (unsuccessfully) to determine what the correct syntax
would be for sed to substitute a given expression with multiple newlines.
For example, someone from an IBM environment ftp'd a file to me (VAX UNIX
System 5.2.2) which is in an IBM printer format.  Except for the first line
in the file, the beginning of each line in this file (it's over 4 megs) has
a leading space, followed by the printer control character (e.g., 1 for
top of page, 0 for double-space, - for triple-space, or a blank for space).
(The first line has a + in column 1, and a 1 in column 2, followed by the
data.)  It seems to me that sed would be the utility to use to convert
these characters.

My problem is with trying to embed newlines in this file.  For example,
I would like to do something like the following:

    s/^ 0/\
    /

where the backslash is to escape a newline character (i.e., substitute
a newline for the ' 0', effectively giving me double-spacing), whenever
the first two characters on a line are ' 0'.  The most I can get it to do 
is either just remove the ' 0' at the beginning of the line, or I manage to 
get an embedded newline in *every* line in the file.  Can someone with a 
little more expertise please help me out?

Thanks in advance,

Grace Quilico
Technical Liaison
<quilico at cecom-2.arpa>
AV 995-2275
Comm: (201) 544-2275



More information about the Comp.unix mailing list