Quantcast
Viewing latest article 1
Browse Latest Browse All 2

Answer by madneon for Check if a screen is active and then display countdown

Do you want to do some countdown, while screen is active? If so, you could change your if and for with while loop, like this:

while (screen -list backup|grep -q backup); do
    # delay
    sleep 1

    # display another dot
    echo -n .
done

This displays a dot every second until your screen session terminates. As for countdown, how would you even know proper starting time (how many seconds to count)?


As alternate, if you want repeating animation of 3 dots:

# init counter
i=0;
while (screen -list backup|grep -q backup); do
    # delay
    sleep 1

    # display dot
    echo -n "."

    # increase conter
    i=$((i+1))

    # on every 3rd loop...
    if [ $i -gt 3 ]; then
        # ...reset counter...
        i=0

        # ...and clear current line and return the cursor
        echo -en "\r\e[K"
    fi
done 

Viewing latest article 1
Browse Latest Browse All 2

Trending Articles