Search the web
Sign In
New User? Sign Up
geeksthatgawk · for GNU Awk questions & discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
problems with data format   Message List  
Reply | Forward Message #93 of 221 |
Re: problems with data format

Hi ya Urszula

Hope you're well. It doesn't seem that complex.

Are your lines:

u> -3.085902 (1a)
u> -0.40908 (2a)
u> 1.968368 (3a)
u> -3.79142 (4a)
u> -3.79142 (5a)
u> -3.79142 (6a)
u> -1.135603 (1b)

Like in groups of 6 ? Or is that just convient notation ?

A normal awk pattern would pick these up...

#- all
{
if( $2 == "1a" ){
a_total = a_total+$1;
}
else if( ( $2 == "2a" ){
a_total = a_total+$1;
}
else if( $2 == "3a" ){
a_total = a_total+$1;
}
else .... #more sums

}

If you want to refine that like who is a "b" or a "1", etc.

YOU can be pedestrian and use simple C style logic.

(substr($2, 1, 1) == "a"){ # First char of 2nd column
#do stuff
}

Awk is very powerful, etc, etc.... Unless you are investing in a big
code-to-last-7 years kind of thing, why sweat it.

If you are investing in a 10,ooo year project, that's OK too. Make
it work and refine it later.

Aloha,
Will.


--- In geeksthatgawk@yahoogroups.com, "uhg_kwant" <ulka@1...> wrote:
> Hi
>
> Thanks for answering - I kinda desperate!
>
> # delete unimportant lines between regular expressions and
> pipe it to awk
> awk 'NR == 11,NR == 16 {print $4} NR == 25,NR ==30 {print $4} NR ==
> 39,NR== 44 {print $7}'
> # from proper lines print needed column
> done





Sun Dec 28, 2003 12:47 am

chiron_sun
Offline Offline
Send Email Send Email

Forward
Message #93 of 221 |
Expand Messages Author Sort by Date

Hi Thanks for answering - I kinda desperate! I have something like that: for i in $(ls *); do #here it is for files in a loop sed '/something/,/something/d' $i...
uhg_kwant
Offline Send Email
Dec 9, 2003
10:33 pm

Hi ya Urszula Hope you're well. It doesn't seem that complex. Are your lines: u> -3.085902 (1a) u> -0.40908 (2a) u> 1.968368 (3a) u> -3.79142 (4a) u> -3.79142...
William
chiron_sun
Offline Send Email
Dec 28, 2003
12:47 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help