Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Redirect from command output

6 views
Skip to first unread message

Cecil Westerhof

unread,
Jan 9, 2014, 6:47:40 PM1/9/14
to
At the moment I have the following code:
vmstat -n ${INTERVAL} | {
read line
read line
read line
while read line ; do
store-vmstat ${line}
done
}

This does what I want, but with the pipe there is a fork that should not
be necessary.

I tried the following:
{
read line
read line
read line
while read line ; do
store-vmstat ${line}
done
} <<< "$(vmstat -n ${INTERVAL})"

Redirecting from the output of a command does work, but it looks like
the redirection only starts after the command is finished and this
command never finishes.

I also tried:
} <<< "$(stdbuf -oL vmstat -n 10 15)"
and:
} <<< "$(pty vmstat -n 10 15)"

to no avail. Does anybody know how to do this, or is the pipe solution
the way to go?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Cecil Westerhof

unread,
Jan 11, 2014, 10:04:13 AM1/11/14
to
Op Friday 10 Jan 2014 00:47 CET schreef Cecil Westerhof:
It can be done with:
} < <(vmstat -n ${INTERVAL})

But it does not make a difference qua processes. So it does not better
performance. (But I find the style better.)
0 new messages