1

In my bash script, I'd like to have a ticking clock on the first line of the screen and have other text below it, but I don't want to write the text to the screen every time the clock ticks. In other words, I have this:

15:00:25 Tue Aug 30 2016
The quick brown fox 
jumps over the lazy dog

I want the first line to change every second without rewriting the last two lines.

2
  • do you need to do something else at the same time, or do you just want the clock?
    – ilkkachu
    Aug 30, 2016 at 19:06
  • Um, maybe I don't understand your question, but I think I just want the clock. What kind of "something else" are you thinking?
    – aswine
    Aug 30, 2016 at 19:11

1 Answer 1

2

Various terminal tricks are possible, e.g.

#!/bin/sh

emitdate() {
  tput sc
  tput cup 0 0
  date
  tput rc
}

clear
echo
echo tqbf
echo jotld

while :; do
  emitdate
  sleep 1
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .