Thread: awk on non stop stream

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you're calling it from popen, then it's your responsibility in the program to do what you need to do with it, because that's where the output is going. The shell can't help you now, because you've already bypassed the shell. You can't do both.

  2. #17
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Quote Originally Posted by TuXaKoS View Post
    well i use
    Code:
     application | cut -f1 | awk {'print $1'}
    but it doesn't work. Why?
    I am never one to try optimising prematurely, but this is an exception. Every time you invoke cut, you fork a new process in a subshell. Every time you invoke awk, you fork a new process in a subshell. So in this case, in one line, you are forking (at least) two processes. On even relatively small files, this is incredibly slow compared to using the shell's own built in ability to do the same kind of work (which won't fork any processes). Have a look at this to see what I am getting at. I think you will be surprised by what you read there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. mistake of using awk
    By lehe in forum Linux Programming
    Replies: 6
    Last Post: 04-02-2009, 04:41 PM
  2. Closing a stream
    By cunnus88 in forum C++ Programming
    Replies: 8
    Last Post: 02-21-2008, 05:15 PM
  3. Help! About text stream and binary stream
    By Antigloss in forum C Programming
    Replies: 1
    Last Post: 09-01-2005, 08:40 AM
  4. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM
  5. Getting an input stream to stop creating a file
    By Stevek in forum C++ Programming
    Replies: 3
    Last Post: 03-21-2003, 04:45 PM