edit first line of long file

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Oct 24 07:44:21 AEST 1990


In article <568 at inews.intel.com> bhoughto at cmdnfs.intel.com (Blair P. Houghton) writes:
> In article <27338 at shamash.cdc.com> ddh at dash@udev.cdc.com (Dan Horsfall) writes:
> >Plan A: pass the whole file thru sed, qualifing the search string
> >as "1s/.../.../"; sed will look at each line of the file.
> sed is the way.

No, it's not. Try head -1 | sed 's/.../.../'; cat.

> Anything else
> would involve multiple exec's and pipes and several context
> switches for each character of data, and then you get
> process and I/O collisions.

Hyperbole. No sane program does several context switches for each
character of data, and ``process and I/O collisions'' don't exist. sed
does much more processing on each character than cat does. On this
machine, sed is more than 12 times slower than cat.

> I'll predict nothing (except
> perhaps awk or certainly perl or C) would be faster than
> the sed line, and by posting to the net you've just cost
> yourself and the world more time, bytes, and money than any
> of these choices could possibly be worth.

Your prediction is wrong, and it's the hope of everyone who participates
in technical discussions that information received is worth money spent.

---Dan



More information about the Comp.unix.questions mailing list