edit first line of long file
Paul John Falstad
pfalstad at shine.Princeton.EDU
Thu Oct 25 00:19:59 AEST 1990
In article <2164 at sixhub.UUCP> davidsen at sixhub.UUCP (bill davidsen) writes:
>In article <4597:Oct2321:44:2190 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>$ time { head -1; sed 's/foo/bar/'; cat; } < x.tmp > /dev/null
>
>real 0m3.16s
>user 0m1.86s
>sys 0m0.70s
>$ exit
>Script ended [y.tmp] at Tue Oct 23 23:05:28 1990
>
> How 'bout that! The overhead of all the other stuff made it slower. I
>guess I'll vote for using just plain sed, because it's easier, faster,
It has the added bonus that it works. I tried the following on my
system:
% cat >foob
foo
bar
^D
% ( head -1 | sed 's/foo/bar/' ; cat ) <foob
bar
%
However, the following does work:
% ( head -1 | sed 's/foo/bar' ; cat )
foo (me)
bar
foo (me)
foo
bar (me)
bar
%
The latter works because the tty groups the input by line. The first
packet goes to head, and the rest of the packets go to cat. Everything
works fine. In the former case, the input is grouped by blocks. Since
I have such a small test file, head grabs the whole input, passes the
first line to its output, and throws the rest away. If I try this with
/usr/dict/words, the first line gets passed through sed, the rest of
the first block gets junked, and cat prints the rest of /usr/dict/words,
skipping everything before 'annihilate.'
So apparently head and cat only work if you type the input at the tty.
Not very useful. Oh well.
--
This is a delicate, sensitive, well-brought-up game which does not recognize
the word... well, Whatever it was you just said that we do not recognize.
What would Miss Manners say? Who the fuck do you think you are, anyway?
Please use another, nice word instead. [from the game Bureaucracy]
More information about the Comp.unix.questions
mailing list