The Archives

  • 08.Nov.08
    Is this a tty? shell | pfortuny | (0)
    That is a funny question to ask if you are a human (because you *should* know the answer). But it is not that dumb for a system. As a matter of fact, among the multiple tests the shell admits (man 1 test), there is a -t which serves specifically for that: $ test -t 0 returns 0 (that is, success or true in shell jargon) if the standard input (file descriptor 0) is open and is associated with a terminal. So, unless things are going pretty bad, the following $ test -t 0 && echo $? Should always print a 0. However, when a file ...
  • 23.Oct.08
    Nix all output cmd | pfortuny | (1)
    $ cat /var/mail/* >/dev/null 2>&1 The first redirect sends stdout to /dev/null, the second one sends stderr to stdout, thus making all the output disappear. Useful in cron jobs if you want no mail sent.