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!

grouping and aggregating

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all,
Got a sed pre-processed file like:

RS0ISS 12:14:47
RS0ISS 12:17:01
RS0ISS 15:09:10
F5ZNJ 07:08:59
F5ZNJ 09:33:06
...etc

and would like to have the following:

RS0ISS 12:14:47,12:17:01,15:09:10
F5ZNJ 07:08:59,09:33:06
...etc

pse, any clues, tnx in advance.
 
BEGIN {
OFS=","
}

{
arr[$1] = ($1 in arr) ? arr[$1] OFS $2 : $2

}

END {
for (i in arr)
printf("%s%s%s\n", i, FS, arr);

}
 
Great !
it works fine and also save plenty of time for the rest of my project.
I really need to find a good book about this powerful AWK language.
Tnx again :)
 
vgersh99,

One vote from me.

I see now my awk knowledge is humble.
I'm finely going to buy a book now.

Regards Gregor. Gregor.Weertman@mailcity.com
 
I recommend Sed & Awk by Dale Dougherty & Arnold Robbins from O'Reilly & Assoc CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top