First-line-only editing, part 2: Portable solutions

Dave Burton daveb at nostromo.austin.ibm.com
Fri Nov 9 04:42:47 AEST 1990


In article <16471:Oct2420:13:4390 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
|As shown in my previous message, sed is much slower than a head-sed-cat
|combination on a particular 300K file. ...
| So the fastest portable solution I've seen is
|  head -1 file | sed 's/.../.../'; tail +2 file

In article <4031 at awdprime.UUCP> daveb at bach.austin.ibm.com (Dave Burton) writes:
|[ no, try: ]
|sed 's/.../.../;1q' < file > outfile

which, of course, doesn't output the entire file.  Therefore, it seems that
the "fastest portable solution" [we've] seen is:

sed 's/.../.../;1q' file; tail +2 file
	or
(sed 's/.../.../;1q'; tail +2) < file

Now, truly, nuff said. :-)
--
Dave Burton
inet: daveb at bach.austin.ibm.com
uucp: cs.utexas.edu!ibmchs!auschs!nostromo!daveb



More information about the Comp.unix.questions mailing list