Help with sed Syntax
    dce at mips.UUCP 
    dce at mips.UUCP
       
    Thu Oct 23 05:19:49 AEST 1986
    
    
  
(Original article asks how to replace '^ 0.*' with a newline and the data.
I would have replied directly but had too much trouble with the address.)
One way is to do something like:
	s/^ 0\(.*\)$/\
	\1
This says 'replace the sequence <space>0<text> with a newline followed by
the text'.
You might also consider using awk for the whole thing. For example, the
following awk script will convert a leading " 1" to an extra newline,
and a leading " 2" to two extra newlines. It could be easily modified
to understand formfeeds and other controls.
	{
		if (substr($0, 1, 1) != " ") {
			print substr($0, 3);
			next;
		}
		Cntl_char = substr($0, 2, 1);
		if (Cntl_char == "1") {
			print "";
		} else if (Cntl_char == "2") {
			print "\n";
		}
		print substr($0, 3);
	}
			David
    
    
More information about the Comp.unix
mailing list