From wprager@newbridge.com Thu Jul 29 18:23:42 1999 Path: fu-berlin.de!fu-berlin.de!newspeer.monmouth.com!nf1.mgmt.sympatico.ca!news1.bellglobal.com!kannews!kannews!not-for-mail From: Walter Prager Newsgroups: comp.editors Subject: Re: writng to a file Date: Wed, 28 Jul 1999 10:32:02 -0400 Organization: Newbridge Networks Corporation Lines: 33 Distribution: inet Message-ID: <379F1462.213AE25C@newbridge.com> References: <379E04BC.E251EA13@bdsinc.com> NNTP-Posting-Host: frasier.ca.newbridge.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: kannews.ca.newbridge.com 933172051 20871 138.120.52.123 (28 Jul 1999 14:27:31 GMT) X-Complaints-To: usenet@kannews.ca.newbridge.com NNTP-Posting-Date: 28 Jul 1999 14:27:31 GMT X-Mailer: Mozilla 4.6 [en] (X11; U; SunOS 5.6 sun4u) X-Accept-Language: en Xref: fu-berlin.de comp.editors:39113 Dan Fluet wrote: > > How do I save all the records between the last names Moore and Morris to > a file without using redirection just sed commands? > > Dan You can do it easlily enough with awk, if you don't need to replace the same file with the results: cat | awk '/Moore/,/Morris/' > The same can be done with sed, if you wish: sed '/Moore/,/Morris/ w ' I'm not sure you can use sed to replace the file being read (it will truncate any output file before it begins processing any input file). You can use ex as well, passing it two commands: ex -s -c '/Moore/,/Morris/ w\!' -c 'q' The -s is to suppress output (number of characters written and so one), the first -c command is to write (! is to force partial buffer write -- must be preceded with \ to suppress shell substitution), the second -c command simply quits. -- Walter Prager, S/W Designer | ||| "I don't have all the answers. In TEL: (613) 599-3600 ext 6460 | |||||||| life, to be honest, I've failed as EMAIL: wprager@newbridge.com | ||||\||| much as I've succeeded. But I love | ||||\\|| my wife, I love my life, and I wish NEWBRIDGE NETWORKS CORP | ||||\\\| you *my* kind of success." Kanata, Ontario, Canada | ||| Dicky Fox