Path: utzoo!attcan!uunet!cs.utexas.edu!romp!auschs!d75!awdprime!nostromo.austin.ibm.com!daveb From: daveb@nostromo.austin.ibm.com (Dave Burton) Newsgroups: comp.unix.questions Subject: Re: First-line-only editing, part 2: Portable solutions Message-ID: <4031@awdprime.UUCP> Date: 25 Oct 90 21:17:27 GMT References: <16471:Oct2420:13:4390@kramden.acf.nyu.edu> Sender: news@awdprime.UUCP Reply-To: daveb@bach.austin.ibm.com (Dave Burton) Organization: IBM AWD, Austin, TX Lines: 19 In article <16471:Oct2420:13:4390@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: |X-Original-Subject: Re: edit first line of long file |As shown in my previous message, sed is much slower than a head-sed-cat |combination on a particular 300K file. ... Not (necessarily) so. | So the fastest portable solution I've seen is | head -1 file | sed 's/.../.../'; tail +2 file Try: sed 's/.../.../;1q' < file > outfile Nuff said. -- Dave Burton | "You can lead a moron to water, daveb@nostromo.austin.ibm.com | but you can't make him think." cs.utexas.edu!ibmchs!nostromo!daveb | -- stevea@i88.isc.com