Created
May 7, 2021 03:14
-
-
Save askrabal/88c4a83b966d81b60d1483862a5303d0 to your computer and use it in GitHub Desktop.
Simple bash script to show how to continuously print on 2 lines
This file contains hidden or 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
#!/bin/bash | |
reprintLines() { | |
let -i end=$1 | |
for (( ii=0; ii < end; ii++));do | |
echo -ne "\033[2K" #clear line | |
echo -ne "\033[1A" # go up 1 | |
done | |
echo -ne "\033[G" #move to begin of line | |
} | |
for ii in {0..10};do | |
printf "Lets count to 10!\n" | |
printf "%3d\n" "$ii" # don't print \n | |
sleep 1s | |
if [[ $ii -lt 10 ]];then | |
reprintLines 2 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment