a continous `date` script
Results 1 to 3 of 3

Thread: a continous `date` script

  1. #1
    Join Date
    Nov 2000
    Location
    buenos aires
    Posts
    335

    a continous `date` script

    in a `command line only` machine, is there any way to echo the date command, specially the hour, to the screen, but that the same keeps refreshing, until i press a key, or i do a `ctrl + c`?
    i`ve read all the bash scripting documentation that i found in inet, but found nothing.
    the closest thing i found was the `\r` command, but that doesn`t work.
    any help will be much welcomed. i`m totally new to scripting/programming in general.

  2. #2
    Join Date
    Apr 2000
    Posts
    775
    Use Curses. By performing a destructive backspace, you can do something like:

    Wed 31 Jan 2001 01:10:49 << print time
    Wed 31 Jan 2001 01:10: << two backspaces
    Wed 31 Jan 2001 01:10:50 << print new digits
    Wed 31 Jan 2001 01:10:5 << one backspace
    Wed 31 Jan 2001 01:10:51 << replace last digit

    repeat that last for next 9 seconds, then backspace 4 characters and print 01:11:00 etc.

    In a shell:

    #!/bin/sh
    bs=$(tput cub1) # Read the tput(1) and terminfo(4) man pages
    x=0

    while [ "$x" -lt 10 ] ; do
    echo -n $x; sleep 1; echo -n "$bs"
    done

    [This message has been edited by Prince (edited 01-31-2001).]

  3. #3
    Join Date
    Nov 2000
    Location
    buenos aires
    Posts
    335
    prince, thanks, i don`t comletelly understand what you`re trying to tell me, but i`ll try that tonight at home, thank you very very much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •