Message Of The Day

Mon, 26 Apr 2004

19:16 [zork(~/sam/admin-spotting)] cat slothly.txt

Slow Down There Buddy

This chunk of code allows you to add a little artificial slow down to your bash scripts. Add it to the top of the shell script and watch ... everything ... pass ... by ... real ... slow.

Especially useful with set -x.

sleep_some () { sleep 1; }
trap sleep_some DEBUG

Mon, 12 Apr 2004

09:25 [zork(~/sam/admin-spotting)] 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(~)] cat README