From: ara.t.howard@... Date: 2006-09-29T01:09:09+09:00 Subject: Re: how to determine if pipe is given On Fri, 29 Sep 2006 gwtmp01@mac.com wrote: > In both cases if you leave off the '-' the program will report an error > rather than reading and processing the data. The next programmer > who comes along is going to be very confused by this behavior. not if they work on unix! ;-) > Can anyone think of a standard Unix program that will *only* read from > stdin in if you give an explicit sentinel as a file argument? # # tarfile on stdout # harp:~ > tar -cf - directory > tarfile_on_stdout.tgz # # piped tarfile on stdin # harp:~ > tar -cf - directory | tar -xvf - # # copying files overnetwork via piped tarfile and unpacking on the other side # harp:~ > (cd /src; tar -cvf - foo) | (ssh other.machine 'cd /dst; tar -xf -') # # echo foobar into a gzip of stdin, sending compressed output to stdout, pipe # that into another gzip which is decompressing stdin, dump that output back # out to stdout # harp:~ > echo foobar | gzip - -c | gzip -d - -c foobar # # use image magick's convert command to convert stdin -> stdout # harp :~ > convert - - < map.png > map2.png harp :~ > file map2.png map2.png: PNG image data, 713 x 569, 8-bit/color RGB, non-interlaced # # grep for list of patterns on stdin # harp:~ > echo alias | grep -f- .bashrc alias new='ls -ltar' alias p="fetchmail;pine -i -passfile /home/ahoward/.passfile" alias g="glimpse -n -H" alias gi='glimpseindex -B -t -f -H' alias ldate='env TZ=America/Denver date' alias ssh='ssh -X' alias vi='vim' alias mussel='tti -A nrt@mussel.ngdc.noaa.gov' alias ss='screen -S ' alias sl='screen -list ' alias sdr='screen -d -r ' alias s='screen -D -R ' alias dark='eval `dircolors /etc/DIR_COLORS` && export DIR_COLORS=dark' alias light='eval `dircolors /etc/DIR_COLORS.xterm` && export DIR_COLORS=light' alias xt="xterm -font 7x13 -fb 7x13B -geometry 80x25 -sb -wf -j -ls -bg Black -fg grey &" note that none of these are documented. i think that's because it's considered 'standard' bahaviour. cheers. -a -- in order to be effective truth must penetrate like an arrow - and that is likely to hurt. -- wei wu wei