$ mkfifo A.fifo B.fifo
$ cat > A.sh << EOF
#! /bin/bash
while :
do
read i < ./A.fifo
echo $i bottles of beer on the wall, $i bottles of beer.
echo $((i+1)) > ./B.fifo
done
EOF
$ cat > B.sh << EOF
#! /bin/bash
max=99
while :
do
read i < ./B.fifo
((i-=2))
if [ "$i" -le "0" ]
then
i=$max
echo Take one down and pass it around, no more bottles of beer on the wall.
echo
echo No more bottles of beer on the wall, no more bottles of beer.
echo Go to the store and buy some more, $i bottles of beer on the wall.
else echo Take one down and pass it around, $i bottles of beer on the wall.
fi
echo
echo $i > A.fifo
done
EOF
$ chmod +x A.sh B.sh
$ ./A.sh &
$ ./B.sh &
$ echo 99 > A.fifo
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.
96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.
95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.
94 bottles of beer on the wall, 94 bottles of beer.
Take one down and pass it around, 93 bottles of beer on the wall.
93 bottles of beer on the wall, 93 bottles of beer.
Take one down and pass it around, 92 bottles of beer on the wall.
92 bottles of beer on the wall, 92 bottles of beer.
Take one down and pass it around, 91 bottles of beer on the wall.
91 bottles of beer on the wall, 91 bottles of beer.
Take one down and pass it around, 90 bottles of beer on the wall.
90 bottles of beer on the wall, 90 bottles of beer.
Take one down and pass it around, 89 bottles of beer on the wall.
89 bottles of beer on the wall, 89 bottles of beer.
Take one down and pass it around, 88 bottles of beer on the wall.
88 bottles of beer on the wall, 88 bottles of beer.
Take one down and pass it around, 87 bottles of beer on the wall.
87 bottles of beer on the wall, 87 bottles of beer.
Take one down and pass it around, 86 bottles of beer on the wall.
86 bottles of beer on the wall, 86 bottles of beer.
Take one down and pass it around, 85 bottles of beer on the wall.
[...etc...] |