Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also make a demo of 'tail -f' and 'multitail' tool, which seems promising for us to use.
- Loading branch information
Andy C
committed
Jan 19, 2024
1 parent
356a420
commit 76019c8
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
set -o pipefail | ||
set -o errexit | ||
|
||
print-output() { | ||
local begin=${1:-1} | ||
local end=${2:-10} | ||
|
||
for i in $(seq $begin $end); do | ||
echo $i | ||
sleep 0.1 | ||
done | ||
} | ||
|
||
parallel() { | ||
print-output 1 10 & | ||
print-output 11 20 & | ||
wait | ||
wait | ||
echo done | ||
} | ||
|
||
parallel2() { | ||
mkdir -p _tmp | ||
print-output 1 10 >_tmp/d1 & | ||
print-output 11 20 >_tmp/d2 & | ||
|
||
# Hm the output is not good because it prints too much | ||
# also --pid would be nice for stopping | ||
#tail -q -f _tmp/d1 _tmp/d2 | ||
|
||
multitail _tmp/d1 _tmp/d2 | ||
|
||
wait | ||
wait | ||
echo done | ||
} | ||
|
||
# TODO: try this | ||
# https://www.vanheusden.com/multitail/ | ||
|
||
"$@" |