Hello,
I run an application which output is non-stop. Is it possible to use awk or something else to see only selected columns?
thx
Hello,
I run an application which output is non-stop. Is it possible to use awk or something else to see only selected columns?
thx
You can script awk, so yes. You would write a script to process stdin, this could be done in any language, not just awk.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
well i usebut it doesn't work. Why?Code:application | cut -f1 | awk {'print $1'}
If u let me know what your trying to monitor with the awk script i can write u a one line perl script ??
Newk
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.
well the ouput have 11 columns. I want only the 1,2,6,8,11.
ok, as far as i can see from a few tests
what u need is
application | awk '{ print $1, $2, $6, $8, $11}'
that should work
Newk
I tryed already, it doesn't work :/ maybe (?) because the applications output is non stop?
Do u need the formatted output as it comes out?? or wud after its run work too?
Newky
I need the formatted output as it comes out.. :/
I'm forgetting my shell scripting, but what about something like
Code:application& > temp_file while true; do tail temp_file | awk whatever; done
can i do it without creating a file? is it possible something like that application | awk ... ?
Pipe isn't going to pass anything along until the first process terminates, I'm pretty sure.
dawm :/ i don't want to create a file because the stream is non-stop and if the application runs for a long time it'll create a huge file :/. There isn't something like the line-line buffer you suggested me before?
You probably then want to redirect the output of your application to your script. Maybe something like
Code:while true; do read var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11; #There's probably a shortcut for this echo "$var1 $var6 $var8 $var11"; done