Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: tee-like file redirection in shell?



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@xxxxxxxxxxxxxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author