[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] sed Help




And Lo! The Great Prophet " Dawson, Alan" uttered these words of wisdom...
>
> ...[more stuff]...
>

And finally ... a way to do the required task without even touching sed, awk
or perl ...

        while read x; do echo /whatever/$x; done < infile > outfile

And there's probably a multitude of other ways, but I'll leave it here. As
for the best to use, it's a toss-up between readability and expense. I've
not ran time over any of the suggestions, but any difference is probably
negligable anyway given the simplicity of the task in hand. I'd suspect the
above is the fastest, unless "echo" is /not/ a shell builtin, in which case
it would certainly be the most expensive (forking an 'echo' for each input
line). Getting rid of pipelines also saves on forks.

As far as sed, perl and awk are concerned, which is the fastest to load and
startup? Methods that don't use RE's are probably better (RE's can be "slow"
to parse if complex), so that rules out sed and some of the perl versions.
So that leaves other perl verions and awk. Out of the two, I'd *suspect* the
awk version will be quicker as less of an overhead compared to perl. But no
timings to prove this :)

Chris...making simple tasks complex

-- 
\ Chris Johnson                 \
 \ cej [at] nightwolf.org.uk          \
  \ http://cej.nightwolf.org.uk/  ~-----------------------------------+
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____



___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.