bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'time' redirection, and pipe redirections in general


From: Linda Walsh
Subject: 'time' redirection, and pipe redirections in general
Date: Fri, 24 Jul 2009 18:59:43 -0700
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

Dave B wrote:
On Friday 17 July 2009, Linda Walsh wrote: (majorly abbreviated)
where output 'time' cmd "go"? I.e. Howto pipe_ 'time' output to _prog_ [?]
<small>or file<small>?

Please see http://mywiki.wooledge.org/BashFAQ/032
----
An excellent and thorough webpage, but it doesn't exactly answer my question. The example, BTW, using 'exec' and the file descriptor
reassignments is 'intense'.  Had to study it a bit...:-).
Didn't know that the "-" at the end of "3>&1-" meant to close the old after duping it to the new. Much good arcana. My brain need to grow some
more neurons! :-)

 What I really wanted most was the pipe-to-prog part of the solution,
which I think I finally solved (though not separating stderr from the
time command output:

(time ls) 2>&1 1>/dev/null |myprog
 OR (if you want to see stdout, but only pipe stderr...)
for ((i=0;i<10;++i));do
time ls
done 2>&1 1>/dev/tty |my_stderr_prog
---
  The 3rd example under "CommandSubstitution" might  be
a template for me to use to separate out the progs stderr from
time.  I, _really_, have _little_ practice with using exec to only
re-direct file descriptors.
 AFAIK, I'm still screwed if I want to create more than one
pipe for outputs -- either sending stderr to one pipe and stdout to
another, OR a way of even doing what "tee" does, but built into the
shell, so I could, using the building "tee", a file descriptor as an
output target.
A simple use/example using a bogus construction:
(VVV is over the bogus constructor (at end of 1st line of example):
----------------VVV
(time sysmaint) 2&|\
($c=0;while read ln; do \
if ((++c==1)); then Mail -s Alert admin@localhost & fi; c=$((c+1)) echo $ln;
done;) | (Mail -s "maintlog output for sysmaint" logkeeper@localhost)

 Is it, "just" a syntactic problem? Or is there some other reason
why one can't easily pipe different file descriptors to different
programs (i.e. not redirecting to different files).

Linda





reply via email to

[Prev in Thread] Current Thread [Next in Thread]