Friday, August 4, 2023

Print a character while command is executing in Linux

function printChar

{

    local pid=$!

    local delay=0.50

    local spinstr='...'

    echo "Loading "

    while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do

        local temp=${spinstr#?}

        printf "%s  " "$spinstr"

        local spinstr=$temp${spinstr%"$temp"}

        sleep $delay

        printf "\b\b\b"

    done

    printf "    \b\b\b\b"

echo

}

####

sqlplus -S $ouser/$opass@$oserver @$tmpPth/qry.sql & printChar



No comments: