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.
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.
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.