| 1 | #!/usr/bin/env bash
 | 
| 2 | 
 | 
| 3 | set -o nounset
 | 
| 4 | set -o pipefail
 | 
| 5 | set -o errexit
 | 
| 6 | 
 | 
| 7 | print-output() {
 | 
| 8 |   local begin=${1:-1}
 | 
| 9 |   local end=${2:-10}
 | 
| 10 | 
 | 
| 11 |   for i in $(seq $begin $end); do
 | 
| 12 |     echo $i
 | 
| 13 |     sleep 0.1
 | 
| 14 |   done
 | 
| 15 | }
 | 
| 16 | 
 | 
| 17 | parallel() {
 | 
| 18 |   print-output 1 10 &
 | 
| 19 |   print-output 11 20 &
 | 
| 20 |   wait
 | 
| 21 |   wait
 | 
| 22 |   echo done
 | 
| 23 | }
 | 
| 24 | 
 | 
| 25 | parallel2() {
 | 
| 26 |   mkdir -p _tmp
 | 
| 27 |   print-output 1 10 >_tmp/d1 &
 | 
| 28 |   print-output 11 20 >_tmp/d2 &
 | 
| 29 | 
 | 
| 30 |   # Hm the output is not good because it prints too much
 | 
| 31 |   # also --pid would be nice for stopping
 | 
| 32 |   #tail -q -f _tmp/d1 _tmp/d2
 | 
| 33 | 
 | 
| 34 |   multitail _tmp/d1 _tmp/d2
 | 
| 35 | 
 | 
| 36 |   # UI doesn't have both files?
 | 
| 37 |   #lnav -t _tmp/d1 _tmp/d2
 | 
| 38 | 
 | 
| 39 |   wait
 | 
| 40 |   wait
 | 
| 41 |   echo done
 | 
| 42 | }
 | 
| 43 | 
 | 
| 44 | # TODO: try this
 | 
| 45 | # https://www.vanheusden.com/multitail/
 | 
| 46 | 
 | 
| 47 | "$@"
 |