script help needed --- awk?

hello and thanks in advance.

I need to consolidate 2 records of data into 1 record.

here is a sample of the input:
------------------------------------------------------------------------------------------
totalcount fred thomas 99999.00 88888:00
total 77777.00
------------------------------------------------------------------------------------------
totalcount sally smither 99999.00 88888:00
total 77777.00 66666.00
------------------------------------------------------------------------------------------

Sample records are grouped within the '-------'. I need the data within the '---------' consolidated to look like the output format below

Fred, Thomas, 77777.00, 99999.00, 888888:00
Sally, Smither, 77777.00, 99999.00, 888888:00

If I got it right, just remove the ------ lines and the empty ones, right?

grep -vE "^------|^$" infile > newfile

zaxxon

Yes that is one of the things needed. I now under stand the -v and -E args of grep. ty.

I still need to consolidate a couple of fields on each record in between the '------' to one record...... does that make sense?

I have a base awk statement that i have started. I piped your recommended grep command to it.

grep -vE "^------|^$" $FILENAME | awk '$4="04" { print $1","$2 }'

I have a little time this morning to work on this script... any help would be appreciated. I will be posting the solution.

Go Ferrari!

awk 'BEGIN{RS="-+"; OFS=", "} $2 {print $2, $3, $7, $4, $5 }' your-file

ty.... that works.

I am attempting to read/learn about the important parts of that script/command. Is is a true statement that awk considers everthing between the record seperator RS as one record?

Wow clean and simple.

Again thank you and regrards,

T

I've sat at the beginning of Eau Rouge. That circuit is in a magical place.

A pure Korn shell solution

#!/usr/bin/ksh93

typeset -L1 -u firstF
typeset -L1 -u firstL

while read a b c d e
do
   if [[ $a == "totalcount" ]]; then
       nameF=$b
       nameL=$c
       numD=$d
       numE=$e
   fi
   if [[ $a == "total" ]]; then
       firstF=$nameF
       firstL=$nameL
       print "${firstF}${nameF#?}, ${firstL}${nameL#?}, $b, $numD, $numE"
   fi
done < file

fpmurphy ...

that works... thank you.

                        @\(\#\)PD KSH v5.2.14 99/07/13.2

What is up with the ksh you use? above is the version available on the server i am using... it seems to be a newer version that ksh93... is that correct?

thanks again and regards.