MOTD

Message Of The Day

Mon, 12 Apr 2004

09:25 [zork(~)] cat tricksy.txt

Tales from the Vault

So this is probably a no-no to someone, but it is an intriguing trick. At the beginning of your shell scripts try this on:

cat $1 |
    ... <rest of code>

So let's say you want a program to take input from stdin or from the command line argument. Viola! There you go. If someone does specify an argument then it waits for stdin. Or if you do specify an argument it just handles it. I can imagine a few reasons why it probably isn't good for production code. But damn I like it.


[zork(~)] cal
[zork(~)] tree
[zork(~)] syndicate.py
[zork(~)] cat README