Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Redirect a specific file descriptor to a pipe?
- X-seq: zsh-users 22553
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Redirect a specific file descriptor to a pipe?
- Date: Fri, 10 Mar 2017 17:22:19 +0000
- Cc: Nathan Dorfman <na@xxxxxxxx>, zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=T87y9uRHT3roK10jCp++QuMfUa8Clbncn+Kpq3T8534=; b=B8PxgKtmabjM303Mu9JxXaZHGYE+sKt099ppxN+y6FAfl6pL2iT1+JwBFzRaUnTOjI 6NovQ+rHLgJbF7OJ07TofgYIvQWvF35wppv3vfEuo/qLrnD4f4IDVt1bePIBWRvHX3Dc dCtUybipRCQZdhkyd3+pBkYmWcA1CAspyd5Ifn/EiKYIUOiG27Q64Hs9QZfWfjY7VWzA i953c+OLR1DhqsC7CwuPsKBmlzl7FaFhytepwrKysOBWQnACODv8QwtOLSfzh7KoASYF f7XscCP9lxxucs8zeqWC3xl2E6+Fp5RIJV3pRyp/1VgjjIlwUWp8gUs4xyHSKpmNiPXf YFug==
- In-reply-to: <170309180417.ZM14034__34042.4779606566$1489111700$gmane$org@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Nathan Dorfman <na@xxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADgEyUsOZZZhiJM5JQrdHORt-ehoLJtYmwW8po4=LViuydMFiw@mail.gmail.com> <170309180417.ZM14034__34042.4779606566$1489111700$gmane$org@torch.brasslantern.com>
2017-03-09 18:04:17 -0800, Bart Schaefer:
> On Mar 9, 5:21pm, Nathan Dorfman wrote:
> }
> } strace -o /dev/fd/3 ./a.out > out.log 2> err.log 3>XXX
> }
> } Instead of file XXX, I'd like to send fd 3 to |less. Is it possible?
>
> You just need this:
>
> strace -o /dev/fd/3 ./a.out > out.log 2> err.log 3>&1 | less
[...]
No quite. There are two issues here, one zsh specific:
cmd > file | cmd2
In zsh (with multios on by default) is special and redirects
stdout both to file and cmd2 (and the 3>&1 would also redirect
fd 3 to both).
In Bourne-like syntax, you'd also need to change the order:
strace -o /dev/fd/3 ./a.out 3>&1 > out.log 2> err.log | less
That is, redirect the fd 3 to the same thing as fd 1 at the time
that fd 1 was the pipe, *and then* redirect fd 1 to out.log.
In zsh, to avoid the multios effect, you can do:
{strace -o /dev/fd/3 ./a.out 3>&1 > out.log 2> err.log} | less
or disable multios (set +o multios).
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author