💾 Archived View for thrig.me › tech › openbsd › watch.gmi captured on 2023-09-08 at 17:35:25. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-06-14)

-=-=-=-=-=-=-

watch - execute a program periodically, showing output fullscreen

This command is actually not available on OpenBSD,

    $ watch
    ksh: watch: not found
    $ pkglocate bin/watch | grep watch\$
    $ 

and if you do not know where to locate pkglocate,

    $ pkglocate bin/pkglocate
    pkglocatedb-1.5:databases/pkglocatedb:/usr/local/bin/pkglocate
    $ doas pkg_add pkglocatedb

While watch could probably be ported (or implemented from scratch) a maybe good enough version can be written for /bin/sh

    $ while :; do clear; date +%s; sleep 1; done
    ...
    1665586050
    ^C
    $ 

where : is the null command; sleep in this position might return a non-zero exit status word which may improperly terminate the loop. By the way, the : command can also be used to empty big files

    $ :> big_file_you_do_not_like_the_contents_of_here

via the default clobber. Anyways, a more complicated watch would require porting the program, or writing an equivalent version from scratch, which would probably be a good exercise for some other time.