| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
On 03Jun2017 01:26, Daniel Goldman <[email protected]> wrote:
>"I've got a few remarks about your solution:" - That is very helpful to the
>OP. FWIW, I prefer "folding style" #1. :) Just personal preference. Actually,
>I would instead use temporary files, skip long pipelines. And speed is usually
>a very secondary consideration, IMO. I think readability and maintainability
>are usually much more important. "Avoid premature optimization". Anyway, it
>was nice of you to help educate others.
Just regarding speed, with shell scripts the runtime is often dominated by the
fork/exec cost because so many operations are farmed out to subprocesses.
Because of this it is usually worth spending some thinking time on reducing the
number of commands dispatched for the work (without making the script
unreadable or unmaintainable). I agree about premature optimisation, but the
threshold for _some_ fork/exec reduction is lower with the shell than in other
languages.
Cheers,
Cameron Simpson <[email protected]>