From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6700 invoked from network); 9 Jun 1999 13:40:23 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jun 1999 13:40:23 -0000 Received: (qmail 14397 invoked by alias); 9 Jun 1999 13:40:01 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2367 Received: (qmail 14388 invoked from network); 9 Jun 1999 13:40:00 -0000 Date: Wed, 9 Jun 1999 09:40:32 -0400 From: Sweth Chandramouli To: ZSH Users Subject: tee-like file redirection in shell? Message-ID: <19990609094032.A15964@astaroth.nit.gwu.edu> Mail-Followup-To: ZSH Users Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i is there currently some way to reproduce the effect of the tee command in the shell itself, and if not, what do people think of the idea of adding that ability (either by new file redirectors or by making tee a builtin)? a couple of times recently, i've been caused many problems by the fact that tee is a standalone program, and as such doesn't care about the value of options like clobber; since tee _is_ basically just another form of file redirection, it would be nice to have it's behaviour be consistent with the other forms provided by the shell. -- sweth. -- Sweth Chandramouli IS Coordinator, The George Washington University / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) * From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6967 invoked from network); 9 Jun 1999 13:57:37 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jun 1999 13:57:37 -0000 Received: (qmail 16628 invoked by alias); 9 Jun 1999 13:57:12 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2368 Received: (qmail 16597 invoked from network); 9 Jun 1999 13:56:25 -0000 To: zsh-users@sunsite.auc.dk Path: mason From: mason@primenet.com.au (Geoff Wing) Newsgroups: lists.zsh.users Subject: Re: tee-like file redirection in shell? Date: 9 Jun 1999 13:56:19 GMT Organization: PrimeNet Computer Consultants Distribution: local Message-ID: References: <19990609094032.A15964@astaroth.nit.gwu.edu> Reply-To: mason@primenet.com.au NNTP-Posting-Host: coral.primenet.com.au X-Trace: coral.primenet.com.au 928936579 6922 203.43.15.2 (9 Jun 1999 13:56:19 GMT) X-Complaints-To: usenet@coral.primenet.com.au NNTP-Posting-Date: 9 Jun 1999 13:56:19 GMT User-Agent: slrn/0.9.5.6 (UNIX) Sweth Chandramouli typed: : is there currently some way to reproduce the effect of :the tee command in the shell itself, and if not, what do people :think of the idea of adding that ability (either by new file :redirectors or by making tee a builtin)? a couple of times :recently, i've been caused many problems by the fact that tee :is a standalone program, and as such doesn't care about the :value of options like clobber; since tee _is_ basically just :another form of file redirection, it would be nice to have it's :behaviour be consistent with the other forms provided by the :shell. You need to have the appropriate setopt. See MULTIOS in the manual. Regards, -- Geoff Wing Mobile : (Australia) 0413 431 874 Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12985 invoked from network); 9 Jun 1999 19:56:48 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jun 1999 19:56:48 -0000 Received: (qmail 15185 invoked by alias); 9 Jun 1999 19:56:30 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2374 Received: (qmail 15178 invoked from network); 9 Jun 1999 19:56:29 -0000 To: ZSH Users Subject: Re: tee-like file redirection in shell? References: <19990609094032.A15964@astaroth.nit.gwu.edu> From: Bruce Stephens Date: 09 Jun 1999 20:16:39 +0100 In-Reply-To: Sweth Chandramouli's message of "Wed, 9 Jun 1999 09:40:32 -0400" Message-ID: User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) XEmacs/20.4 (Emerald) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sweth Chandramouli writes: > is there currently some way to reproduce the effect of > the tee command in the shell itself, Yes. This works for me: % ps > some_file | cat You need the multios option set, and I don't recall whether it's the default or not (it probably should be). Is there any nicer way to say "save to a file and show the results" than using the ugly "| cat"? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13623 invoked from network); 9 Jun 1999 21:29:01 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jun 1999 21:29:01 -0000 Received: (qmail 21681 invoked by alias); 9 Jun 1999 21:28:45 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2375 Received: (qmail 21673 invoked from network); 9 Jun 1999 21:28:44 -0000 Date: Wed, 9 Jun 1999 17:29:16 -0400 From: Sweth Chandramouli To: ZSH Users Subject: Re: tee-like file redirection in shell? Message-ID: <19990609172916.A17470@astaroth.nit.gwu.edu> Mail-Followup-To: ZSH Users References: <19990609094032.A15964@astaroth.nit.gwu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i In-Reply-To: On Wed, Jun 09, 1999 at 08:16:39PM +0100, Bruce Stephens wrote: > Sweth Chandramouli writes: > > > is there currently some way to reproduce the effect of > > the tee command in the shell itself, > > Yes. This works for me: > > % ps > some_file | cat > > You need the multios option set, and I don't recall whether it's the > default or not (it probably should be). it's not set by default, but this does do exactly what i want. > Is there any nicer way to say "save to a file and show the results" > than using the ugly "| cat"? i don't know that it's particularly nicer, but something like % ps > some_file > /dev/stdout should at least save a process from being spawned. -- sweth. -- Sweth Chandramouli IS Coordinator, The George Washington University / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) * From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14548 invoked from network); 9 Jun 1999 23:14:38 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jun 1999 23:14:38 -0000 Received: (qmail 27013 invoked by alias); 9 Jun 1999 23:10:44 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2376 Received: (qmail 27004 invoked from network); 9 Jun 1999 23:10:40 -0000 To: zsh-users@sunsite.auc.dk Path: mason From: mason@primenet.com.au (Geoff Wing) Newsgroups: lists.zsh.users Subject: Re: tee-like file redirection in shell? Date: 9 Jun 1999 23:10:35 GMT Organization: PrimeNet Computer Consultants Distribution: local Message-ID: References: <19990609172916.A17470@astaroth.nit.gwu.edu> Reply-To: mason@primenet.com.au NNTP-Posting-Host: coral.primenet.com.au X-Trace: coral.primenet.com.au 928969835 14472 203.43.15.2 (9 Jun 1999 23:10:35 GMT) X-Complaints-To: usenet@coral.primenet.com.au NNTP-Posting-Date: 9 Jun 1999 23:10:35 GMT User-Agent: slrn/0.9.5.6 (UNIX) Sweth Chandramouli typed: :On Wed, Jun 09, 1999 at 08:16:39PM +0100, Bruce Stephens wrote: :> Sweth Chandramouli writes: :> > is there currently some way to reproduce the effect of :> > the tee command in the shell itself, :> Yes. This works for me: :> % ps > some_file | cat :> Is there any nicer way to say "save to a file and show the results" :> than using the ugly "| cat"? : i don't know that it's particularly nicer, but something like :% ps > some_file > /dev/stdout : should at least save a process from being spawned. % ps >&1 >some_file NB: take care with the order, it's not % ps >some_file >&1 Regards, -- Geoff Wing Mobile : (Australia) 0413 431 874 Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16398 invoked from network); 10 Jun 1999 03:16:36 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Jun 1999 03:16:36 -0000 Received: (qmail 6844 invoked by alias); 10 Jun 1999 03:16:05 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2378 Received: (qmail 6837 invoked from network); 10 Jun 1999 03:16:03 -0000 From: "Bart Schaefer" Message-Id: <990610031542.ZM206@candle.brasslantern.com> Date: Thu, 10 Jun 1999 03:15:42 +0000 In-Reply-To: <19990609172916.A17470@astaroth.nit.gwu.edu> Comments: In reply to Sweth Chandramouli "Re: tee-like file redirection in shell?" (Jun 9, 5:29pm) References: <19990609094032.A15964@astaroth.nit.gwu.edu> <19990609172916.A17470@astaroth.nit.gwu.edu> X-Mailer: Z-Mail (5.0.0 30July97) To: ZSH Users Subject: Re: tee-like file redirection in shell? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 9, 5:29pm, Sweth Chandramouli wrote: } Subject: Re: tee-like file redirection in shell? } } On Wed, Jun 09, 1999 at 08:16:39PM +0100, Bruce Stephens wrote: } > Sweth Chandramouli writes: } > } > You need the multios option set, and I don't recall whether it's the } > default or not (it probably should be). It's not set by default because of the way it interacts with globbing. If you do something like echo "Create this file" > * then zsh will write to every file in the current directory (unless the noclobber option is set). } > Is there any nicer way to say "save to a file and show the results" } > than using the ugly "| cat"? } } i don't know that it's particularly nicer, but something like } % ps > some_file > /dev/stdout In addition to the trick that Geoff mentioned using >&1, zsh interprets the path /dev/fd/ magically. So on any operating system, even those that do not support the /dev/fd/ directory, you can use /dev/fd/0 (standard input) /dev/fd/1 (standard output) /dev/fd/2 (standard error) (etc.) So >/dev/fd/1 is the same as >&1, and so forth, except that with the /dev/fd/ files the file descriptor must already exist -- it won't be duplicated from another file descriptor. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com