Jump to content

Recommended Posts

Hello. I just started to learn the awk language and I tried some examples from doc folder. And there is an example like this:

Print the length of the longest input line:

awk '{ if (lenght ($0) > max ) max = lenght ($0) } END { print max }' CV-NA-10mVps02.Txt

and the result was:

[PHASE], 3, 1415, 4

I asumed that this will give me a value not a string, and that line is NOT the longest input line.

Does anyone knows something about AWK arround here or where I can find someone for explanations?

thanx

Link to comment
Share on other sites

Guest saracen480
awk '{ if (lenght ($0) > max ) max = lenght ($0) } END { print max }' CV-NA-10mVps02.Txt

 

the only thing i can see immediately is that the spelling of LENGTH is wrong.....try it spelled this way instead...i dont know AWK at all im afraid, but that is the first obvious thing.

 

rgrds

rob

Edited by saracen480
Link to comment
Share on other sites

I want to use AWK for calculations in some scientific data. I did some experiments and the machine gave me a *.txt file, like this:

A1, A2, A3, A4, ..., An

B1, B2, B3, B4, ..., Bn

C1, C2, C3, C4, ..., Cn

.....................................

M1, M2, M3, M4, ..., Mn

N1, N2, N3, N4, ..., Nn

 

I'm wondering if I could do some operations like:

cap=A3*(B2-B1)+B3*(C2-C1)+...+M3*(N2-N1)

 

Or someone knows some forums on AWK where I can aks some questions?

 

Thanx

Link to comment
Share on other sites

Guest saracen480

hi again,

 

theres an old english phrase - 'sometimes you cant see the wood for the trees'

i know what its like when you are deep in the middle of something....you dont always spot the obvious!

i do a lot of VBA coding, and i have a co worker read everything, not to see if the code is right, but to make sure theres no typos!

 

awk forums

 

http://www.tek-tips.com/threadminder.cfm?pid=271

http://www.codecomments.com/AWK/

 

a useful info site for awk

http://www.student.northpark.edu/pemente/awk.htm

 

search for 'awk forums' in google, theres loads

 

hope this helps

rgrds

rob

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...