Adding to the front of a line

Matthew Flaschen matthew.flaschen at gatech.edu
Wed Jan 21 06:43:33 UTC 2009


David Fox wrote:
> On Tue, Jan 20, 2009 at 3:37 AM, Florian Diesch <diesch at spamfence.net> wrote:
>> Using "seq 1 1000000 " as input the shell codes needs about 18s here
>> while sed needs about 7s.
> 
> 
> I'm not sure that is a fair test. Sure, bash is interpreted, but how
> much "interpretation" really is done by a simple 'seq 1 1000000'?
> Probably not a whole lot, compared to something like a for/next loop
> in the old interpreted Basic machines.

I don't think that's what Florian meant, and it's not what I did.  I did:

seq 1 1000000>sites.txt
time (while read site; do echo "127.0.0.1 $site"; done <sites.txt
>output_file.txt)
time (sed 's/^/127.0.0.1 /' <sites.txt >output_file.txt)

In other words, the sequence is used as input, but not timed.

> For instance, most of the time taken up by 'seq 1 1000000' from a bash
> command line is the time taken up to display all those numbers.

Definitely true.

Matt Flaschen




More information about the ubuntu-users mailing list