News for hackers. Stuff that matters.
Re:Delegating complex treatments to filters in shell program... by falsedan on Friday May 12, 2017 @10:35AM (#14324263)
There's another advantage to using filters in pipelines: each part of the pipeline runs in parallel!

I recently rewrote some bash code to replace

  for subdir in $names
  do
    for parent in $(parent_of $dir)
    do
      [ -d $parent/$subdir ] && …
    done
  done
with

  parents_of $dir | append_subdirs $names | is_dir | xargs …
I expected a modest speed improvement (due to not calculating the parents of a dir repeatedly), but was surprised to see it was twice as fast!

There are no comments on this comment yet.