Live data from Hacker News

Show HN: now.sh

github.com

1–10 of 45 posts

Re: Show HN: now.sh

#5
Hey, I can envisage this being helpful. Thanks. One criticism, which I think has already been voiced, is that you you print to standard error instead of standard out. That way anyone piping to a file won't be surprised when things break if the file is read by something else.

Re: Show HN: now.sh

#7
post #2

Two comments: 1) Really? This is on the front page of HN? 2) why aren't you printing to stderr?

1) Slow news day ... and this being an example of read's -t option put to a good use.

2) Ah, pedantic nitpicking, love it. Because the script is meant for interactive use with no streams redirected off the terminal, and because it doesn't output diagnostics or errors, but rather augments the stdout.

Or put differently - show me an example where writing into stderr would make more sense.

(edit) I guess someone can tee the output afterwards. Fine, I'll make it use stderr.

Re: Show HN: now.sh

#9
Another alternative is 'ts' which is part of joey hess's awesome collection of unix tools, moreutils.[1] I did not find out about ts until too late so I am still in the habit of using tai64n from djb's daemontools, which adds a tai64 timestamp to every file[2] and then tai64nlocal[3] in order to convert the timestamps to something useful to humans.

If you don't know about moreutils check out the collection. I don't know what I'd do without vipe or vidir:

  Chronic: runs a command quietly unless it fails
  combine: combine the lines in two files using boolean operations
  ifdata: get network interface info without parsing ifconfi
  ifne: run a program if the standard input is not empty
  isutf8: check if a file or standard input is utf-8
  lckdo: execute a program with a lock held
  mispipe: pipe two commands, returning the exit status of
  parallel: run multiple jobs at once
  pee: tee standard input to pipes
  sponge: soak up standard input and write to a file
  ts: timestamp standard input
  vidir: edit a directory in your text editor
  vipe: insert a text editor into a pipe
  zrun: automatically uncompress arguments to command
[1] http://joeyh.name/code/moreutils/

[2] http://cr.yp.to/daemontools/tai64n.html

[3] http://cr.yp.to/daemontools/tai64nlocal.html

Re: Show HN: now.sh

#10
post #9

Another alternative is 'ts' which is part of joey hess's awesome collection of unix tools, moreutils.[1] I did not find out about ts until too late so I am still in the habit of using tai64n from djb's daemontools, which adds a tai64 timestamp to every file[2] and then tai64nlocal[3] in order to convert the timestamps to something useful to humans. If you don't know about moreutils check out the collection. I don't k…

If I read ts source right, it merely prepends the current time to every line it echoes from stdin to stdout.

now is different. It re-prints current time once a second while waiting for the input. You basically get the running clock at the last line of output.

Post reply on HN