I copied the below code from some random source to my terminal and ran:
while sleep 1;
do tput sc;
tput cup 0 $(($(tput cols)-29));
date;
tput rc;
done &
The code is to show a running clock at the top right corner of the terminal. The snippet worked very well and exactly did what I wanted it to, but now I just want to end this loop and get rid of the clock.
Also, I need to understand the above code. I've some idea, as I know what tput
command does, but still there're many dots which I'm not able to connect.
jobs
in your session to list active background jobs and then put it to foreground by typingfg <job number>
. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet. – Yurij Goncharuk Apr 30 '19 at 20:48