Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: where did o...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 2181 of 2236
Post > Topic >>

Re: where did output redirection go?

by Janis <janis_papanagnou@[EMAIL PROTECTED] > Mar 7, 2008 at 04:39 AM

On 7 Mrz., 11:58, Tomasz Chmielewski <t...@[EMAIL PROTECTED]
>
wrote:
> Janis schrieb:
>
> >> "out.txt" file is empty, nothing was printed to the screen. Where did
> >> the output redirection go?
>
> > In an I/O buffer that hasn't got filled enough to be flushed
> > before you aborted the process.
>
> > To understand, try...
>
> > while true; do date; sleep 1; done | head -3 | awk '{print $4}' >
> > out.txt
>
> > (BTW, this is off-topic here; comp.unix.shell is more appropriate.)
>
> Actually, it's awk, not shell setting (or any other program that
> buffers, like grep).

No, it's neither awk nor grep that buffers; it's the OS (Unix in
your example).

>
> I solved it in gawk by adding {fflush()}:
>
> iostat dm-1 -d 1 -k | awk '/dm-1/{print $3" "$4}{fflush()}' >output.st
>
> For grep, BTW, the option is "--line-buffered".
>
> --
> Tomasz Chmielewskihttp://wpkg.org

Mind, the buffering is an OS issue, all the pipelines and external
commands is a unix shell issue, and the option you presented is an
tool specific issue (not even standardized), and the only awk'ish
part of the posting is either trivial (print $4) or non-standard
(fflush() seems not be defined by POSIX, according to the GNU docs).

Anyway; glad you've solved the issue once you knew about buffering.

Janis




 5 Posts in Topic:
where did output redirection go?
Tomasz Chmielewski <tc  2008-03-07 10:32:10 
Re: where did output redirection go?
Janis <janis_papanagno  2008-03-07 02:36:03 
Re: where did output redirection go?
Tomasz Chmielewski <tc  2008-03-07 11:58:36 
Re: where did output redirection go?
Janis <janis_papanagno  2008-03-07 04:39:16 
Re: where did output redirection go?
Andrew Schorr <aschorr  2008-03-09 19:26:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 2:49:29 CDT 2008.