zsh-users
 help / color / mirror / code / Atom feed
* tee-like file redirection in shell?
@ 1999-06-09 13:40 Sweth Chandramouli
  1999-06-09 13:56 ` Geoff Wing
  1999-06-09 19:16 ` Bruce Stephens
  0 siblings, 2 replies; 6+ messages in thread
From: Sweth Chandramouli @ 1999-06-09 13:40 UTC (permalink / raw)
  To: ZSH Users

	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
<sweth@gwu.edu> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tee-like file redirection in shell?
  1999-06-09 13:40 tee-like file redirection in shell? Sweth Chandramouli
@ 1999-06-09 13:56 ` Geoff Wing
  1999-06-09 19:16 ` Bruce Stephens
  1 sibling, 0 replies; 6+ messages in thread
From: Geoff Wing @ 1999-06-09 13:56 UTC (permalink / raw)
  To: zsh-users

Sweth Chandramouli <sweth@astaroth.nit.gwu.edu> 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   <gcw@pobox.com>            Mobile : (Australia) 0413 431 874
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tee-like file redirection in shell?
  1999-06-09 13:40 tee-like file redirection in shell? Sweth Chandramouli
  1999-06-09 13:56 ` Geoff Wing
@ 1999-06-09 19:16 ` Bruce Stephens
  1999-06-09 21:29   ` Sweth Chandramouli
  1 sibling, 1 reply; 6+ messages in thread
From: Bruce Stephens @ 1999-06-09 19:16 UTC (permalink / raw)
  To: ZSH Users

Sweth Chandramouli <sweth@astaroth.nit.gwu.edu> 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"?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tee-like file redirection in shell?
  1999-06-09 19:16 ` Bruce Stephens
@ 1999-06-09 21:29   ` Sweth Chandramouli
  1999-06-09 23:10     ` Geoff Wing
  1999-06-10  3:15     ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Sweth Chandramouli @ 1999-06-09 21:29 UTC (permalink / raw)
  To: ZSH Users

On Wed, Jun 09, 1999 at 08:16:39PM +0100, Bruce Stephens wrote:
> Sweth Chandramouli <sweth@astaroth.nit.gwu.edu> 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
<sweth@gwu.edu> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tee-like file redirection in shell?
  1999-06-09 21:29   ` Sweth Chandramouli
@ 1999-06-09 23:10     ` Geoff Wing
  1999-06-10  3:15     ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Geoff Wing @ 1999-06-09 23:10 UTC (permalink / raw)
  To: zsh-users

Sweth Chandramouli <sweth@astaroth.nit.gwu.edu> typed:
:On Wed, Jun 09, 1999 at 08:16:39PM +0100, Bruce Stephens wrote:
:> Sweth Chandramouli <sweth@astaroth.nit.gwu.edu> 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   <gcw@pobox.com>            Mobile : (Australia) 0413 431 874
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tee-like file redirection in shell?
  1999-06-09 21:29   ` Sweth Chandramouli
  1999-06-09 23:10     ` Geoff Wing
@ 1999-06-10  3:15     ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 1999-06-10  3:15 UTC (permalink / raw)
  To: ZSH Users

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 <sweth@astaroth.nit.gwu.edu> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-06-10  3:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-09 13:40 tee-like file redirection in shell? Sweth Chandramouli
1999-06-09 13:56 ` Geoff Wing
1999-06-09 19:16 ` Bruce Stephens
1999-06-09 21:29   ` Sweth Chandramouli
1999-06-09 23:10     ` Geoff Wing
1999-06-10  3:15     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).