Counting seconds until auto-log-off
count=0
while true; do
  printf "\r%d" $((++count))
  sleep 1
done


Your while condition is doing a lot of work just to return true: you launch a subshell, and evaluate  a test giving a 1-character string (which will always return true). Make it simpler and more readable by just executing the true program.

Note that variable names inside an arithmetic expression do not require the leading dollar sign in most cases. That's quietly documented here:


  "Within an expression, shell variables may also be referenced by name without using the parameter expansion syntax."


printf is more portable than echo, if that's a concern for you. I also find it makes your intentions more obvious.

Instead of backing up the right number of characters, just carriage return to the first column and overwrite the previous contents.