hirohitosan Posted September 12, 2006 Report Share Posted September 12, 2006 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 Quote Link to comment Share on other sites More sharing options...
Guest saracen480 Posted September 12, 2006 Report Share Posted September 12, 2006 (edited) 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 September 12, 2006 by saracen480 Quote Link to comment Share on other sites More sharing options...
hirohitosan Posted September 12, 2006 Author Report Share Posted September 12, 2006 the spelling of LENGTH is wrong.... yes, you're right ... it was that, sorry Quote Link to comment Share on other sites More sharing options...
hirohitosan Posted September 14, 2006 Author Report Share Posted September 14, 2006 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 Quote Link to comment Share on other sites More sharing options...
Guest saracen480 Posted September 18, 2006 Report Share Posted September 18, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.