pipe equivalent to /dev/null ???

Chris Calabrese cjc at ulysses.att.com
Thu Sep 13 23:08:40 AEST 1990


In article <3841 at se-sd.SanDiego.NCR.COM> rns at se-sd.SanDiego.NCR.COM (Rick Schubert) writes:
>In <8720001 at hpdmd48.boi.hp.com> oscarh at hpdmd48.boi.hp.com (Oscar Herrera) writes:
>
>>Is there an equivalent 'pipe' like entity to /dev/null ?
>>What I'd like to do is something like this 
>>	anycommand | bitbucket
>
>I've seen responses of
>	anycommand | true
>and
>	anycommand | cat >/dev/null
>
>What about
>	anycommand | :
>?
>
>I'm not sure if this is shell-specific, but it works with the Bourne
>shell and the C shell, at least on our system.
>
>(You mean you thought ":" was a comment indicator?  Try
>
>	: > somefilename
>
>)
>
>-- Rick Schubert (rns at se-sd.sandiego.NCR.COM)

I've been following this thread for some time, and I have
to say that neither '... | true' nor '... | :' will do the trick.
I thought this would be obvious.
'true' and ':' don't read their stdin, thus the process feeding them
would block and never run.  This is hardly what happens with
'/dev/null'.

A slightly better approach than '... | cat > /dev/null' is a trivial
program which reads its input and creates no output.  In fact, I gave
source to just such a program (didn't test it, though) in a previous
posting in this thread.  It's pretty trivial.

On the other hand, ':' and 'true' are perfectly good
null pipe _sources_.  'true | ...' and ': | ...' do exactly the same
thing is '< /dev/null ...'.

What I really want to know is in what situation you _need_ a pipe,
when /dev/null already is there.  The only thing I can think of is
a C program which uses popen() explicity.  This, of course, flies in
the face of the UNIX tool building philosophy.

BTW, '/bin/true' is often implemented as something like:
	#	the true command
	:
Name:			Christopher J. Calabrese
Brain loaned to:	AT&T Bell Laboratories, Murray Hill, NJ
att!ulysses!cjc		cjc at ulysses.att.com
Obligatory Quote:	``pher - gr. vb. to schlep.  phospher - to schlep light.philosopher - to schlep thoughts.''



More information about the Comp.unix.shell mailing list