Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Apr 1997 19:55:18 -0700 (PDT)
From:      Dan Busarow <dan@dpcsys.com>
To:        Steve Howe <un_x@anchorage.net>
Cc:        freebsd-questions <questions@FreeBSD.org>
Subject:   Re: no pipes allowed
Message-ID:  <Pine.UW2.3.95.970429194118.15048I-100000@cedb>
In-Reply-To: <Pine.BSF.3.95q.970429040140.8631A-100000@aak.anchorage.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 29 Apr 1997, Steve Howe wrote:
> why is it that some commands like "ls" and "which" won't accept pipes?

Cause they don't look for arguments on stdin.  How would ls know
that you wanted

	ls

to look for some input on stdin rather than giving a default
list of the current directory?

If you have a real need to do this, look at xargs

echo /etc | xargs ls

> also - how does one get sh scripts to accept piped input ... ?

By reading stdin if you don't have any command line arguments
and you know you need them.

if [ $# = 0 ]; then
	while read X
	do
		echo $X
	done
fi

Dan
-- 
 Dan Busarow                                                  714 443 4172
 DPC Systems / Beach.Net                                    dan@dpcsys.com
 Dana Point, California  83 09 EF 59 E0 11 89 B4   8D 09 DB FD E1 DD 0C 82




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.UW2.3.95.970429194118.15048I-100000>