Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!ll-xn!mit-eddie!genrad!decvax!decwrl!amdcad!amd!intelca!oliveb!glacier!mips!dce From: dce@mips.UUCP Newsgroups: net.unix Subject: Re: Help with sed Syntax Message-ID: <730@mips.UUCP> Date: Wed, 22-Oct-86 15:19:49 EDT Article-I.D.: mips.730 Posted: Wed Oct 22 15:19:49 1986 Date-Received: Thu, 23-Oct-86 22:51:26 EDT References: <4785@brl-smoke.ARPA> Reply-To: dce@mips.UUCP (David Elliott) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 33 (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 0 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