chris blogs

July 2013

26jul2013 · Summer of Scripts: stee

The stee command made an appearance at day 1 already, but it’s so useful to be it deserves its own mention.

While tee(1) copies standard input to standard output as well as the file argument, stee is silent tee and doesn’t copy to standard output (well, it throws the output away).

What’s that good for, you may wonder? Well, it allows you to write into a file without having to setup a shell direction (nor fiddle with argument strings as with dd of=...). This saves you an additional layer of quoting:

% date | ssh localhost 'cat >/tmp/out'
% date | ssh localhost stee /tmp/out

Also, an often overlooked feature of tee is that it supports output to multiple files. stee of course does as well:

% fortune | stee a b c
% sum a b c
51569     1 a
51569     1 b
51569     1 c

# echo min_power | stee /sys/class/scsi_host/*/link_power_management_policy

(Of course, a good shell can do that already internally.)

NP: Die Schnitter—Klöne

Copyright © 2004–2016