in reply to What is faster?

The first snippet makes your script faster at creating a dependancy on an external utility. Unix folk will have no problem, others probably will.

You mean performance? Well that depends.. but if you put a little more effort into it than your second snippet (see the while loop version posted elsewhere), you should be able to reduce the performance difference enough to only matter in pathological cases. Which means that unless you are working on a pathological case, you shouldn't think about performance. Other factors are more important.

Particularly if you have access to the $script's code, it would very probably be far better to add a commandline option or something of the sort so as only to produce the desired output.

Don't microoptimize single operations - particularly if you don't even have a real performance problem yet.

Makeshifts last the longest.