Reputation: 37
I have a bash script.
f1 ()
{
for ((i=1; i<6; i++))
do
a=$(echo -e "\033[41m ")
echo -n " $a";
echo -en "\033[0m";
sleep 1;
echo -en "\b";
echo -n ' '
done
}
f2 ()
{
a=$(echo -e "\033[41m \033[0m")
echo -en "\033[5;50H$a"
for ((i=1; i<6; i++))
do
echo -en "\b"
echo -en ' '
echo -en "\b\b"
echo -n "$a"
sleep 1
echo -en "\033[0m"
done
}
f1
f2
f1 shifts the object to the right; f2 shifts another object to the left;
what can I do to execute both functions at the same time, so that I see both objects move at the same time?
#this wont work
f1 &
f2 &
Upvotes: 1
Views: 92
Reputation: 6223
Run them in background with parallel:
#export functions so parallel can see them
export -f f1
export -f f2
#run both functions
parallel f1 f2
Upvotes: 1