Skip to content

Instantly share code, notes, and snippets.

@askrabal
Created May 7, 2021 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save askrabal/88c4a83b966d81b60d1483862a5303d0 to your computer and use it in GitHub Desktop.
Save askrabal/88c4a83b966d81b60d1483862a5303d0 to your computer and use it in GitHub Desktop.
Simple bash script to show how to continuously print on 2 lines
#!/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