3 ms·
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
by falsedan 9y ago
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!