bug-bash
[Top][All Lists]
Advanced

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

Re: output redirection with process substitution asynchronous?


From: DennisW
Subject: Re: output redirection with process substitution asynchronous?
Date: Fri, 4 Dec 2009 11:18:44 -0800 (PST)
User-agent: G2/1.0

On Dec 4, 12:58 pm, pk <p...@pk.invalid> wrote:
> pjodrr wrote:
> > Hello,
>
> > how can I prefix every line of output of some command with a
> > timestamp?  I thought like this:
>
> > $ exec 3> >(while read line; do echo "$(date): $line"; done)
> > $ seq 4 >&3
> > Friday, December  4, 2009  4:20:29 PM MET: 1
> > $ Friday, December  4, 2009  4:20:29 PM MET: 2
> > Friday, December  4, 2009  4:20:29 PM MET: 3
> > Friday, December  4, 2009  4:20:29 PM MET: 4
>
> > please note that the prompt ($) returns before the command completes.
> > Why is the
> > process substitution asynchronous?
> > Does anybody know of a better way to accomplish this?
>
> What's wrong with
>
> seq 4 | while read line; do echo "$(date): $line"; done

It works for me. Does it not for you? If you're asking why not do it,
then the answer is "why call an external program unnecessarily?".

Sorry, by the way, I missed what you were doing with the file
descriptor on my first read. What is it that you're trying to
accomplish? Are you doing this only to number the lines or is either
seq or the while loop a stand-in for something else?


reply via email to

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