Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help again 3

Status
Not open for further replies.

Murugs

Technical User
Jun 24, 2002
549
US
Hello Friends
Thanks for those who have replied to my earlier post.
Again I am here with a basic doubt.
I have a text format here

Increment 1
-----------
Max value 100
Min Value 200

NODE U1 U2 U3


59 -1.4877E-03 0.000 -0.3494
203 -7.3659E-03 0.000 -1.116

Increment 2
-----------
Max value 150
Min Value 250

NODE U1 U2 U3


59 -1.4877E-03 0.000 -0.3494
203 -7.3659E-03 0.000 -1.116


and so on.. I need to get the values of Maximum,Minimum,U2 (2 values for each node),U3 (2 values for each node) for each increment in to a separate text file.
Please help out.

Regards
MP
 
Also, I just noticed that my previous post is missing the final } CaKiwi
 
Finally got some lines running in my console window.
here are my output when I performed.
I removed the #! /bin/awk -f and did awk -f myscript test.dat and got some lines flowing.

I noticed the output from the second print statement, says to print out the flg value but not able to print the flg value and it prints 1st field , srd field and just flg =.
There is no flg=1 anywhere in the ouput.

I tried to comment the first print statement and it works fine.

But when I comment the print "-> " $1 " " $3 " flg = " flg
The program is silent and doesn't show any output as before.

What is the error
Regards
Murugs
 
What do you get after the line
Code:
->  ELEMENT  PT        SF1         SF2
is printed? I get
Code:
-> ELEMENT SF1 flg = 1
CaKiwi
 
Continuing on my previous post read srd field and just flg =. as 3rd field and just flg =.

Also I noticed that the print $2 " " $3 is not at all being executed in the program even once.

Regards
Murugs
 
FS="([ ][ ]*)|([\t][\t]*)" Vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Hello CaKiwi
Thanks for supporting me patiently all these times.
I figured out the answer and I need to do my homework a lot before asking such questions. Thanks everybody for their responsess. Pardon my slow understanding of your answers.

THANKS A LOT.
Murugs
 
You're welcome, Murugs, but we are all eager to know how you fixed it.

Vlad, I thought that the default FS was any number of tabs and/or spaces so your suggestion above would have no effect. Am I wrong about that? CaKiwi
 
CaKiwi,

at least for nawk the FS default is spaceS - regardless of the number of them.

The poster said:

&quot;My test.dat file has some tabs and fields arranged neatly&quot;

If there multiple tabs [plural], one needs to specify multiple tabs for the FS definition. The paradigm for default FS [single or multiple spaces] does NOT seem to work for single/multiple tabs.

Vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Thanks Vlad, I learnt something so this exercise wasn't entirely wasted. It seems to make sense though. If you have a tab delimited file and there are 2 tabs in a row, it usually means you intend to have a null field between them. CaKiwi
 
Hello CaKiwi
I did a silly mistake which caused the thread to become too long. Thanks again and suggest me a good beginner book for awk and shell programming.

Regards
Murugs
 
Thread too long?
Never.
This forum is hardly busy most the time anyway.

I'll put in a vote for a good beginner awk book
and an incredibly helpful source for advanced
GNU awk users which is:
Arnold Robbins
&quot;Effective Awk Programming&quot;
Pub SSC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top