On 2007-05-31, Piers Kittel <[EMAIL PROTECTED]> wrote: > > "181","1324.014027","111.111.111.111","111.111.111.111","RTP","Payload t > ype=ITU-T H.261, SSRC=2008229573, Seq=54520, Time=1725612773, Mark" > "185","1324.078941","111.111.111.111","111.111.111.111","RTP","Payload t > ype=ITU-T H.261, SSRC=2008229573, Seq=54521, Time=1725616276" > > I need to convert the above to the below: > > "181","1324.014027","111.111.111.111","111.111.111.111","RTP","54520" > "185","1324.078941","111.111.111.111","111.111.111.111","RTP","54521" > > What's the best way to do this? I've been reading the man pages of > sed, cut and awk but I can't quite figure out how to do this. Any > ideas? >
If I understand what you want, you need the fields 1-5 and 8 from a comma-delimited record. At least, that's what cut will see - the quotes around Payload...Mark will get ignored if you tell cut to use a , as delimiter: cut -d, -f1,2,3,4,5,8 Then you just need to get rid of the Seq= line, which sed will do with: sed s/Seq=//g So put them together: cut -d, -f1,2,3,4,5,8 input.file | sed s/Seq=//g That looks almost right. I'm missing the quotes around the last field. Two more sed commands fix this: cut -d, -f1,2,3,4,5,8 input.file | sed -e s/Seq=//g -e 's/, /,"/g' -e 's/$/"/g' That seems to do the job with your example text. HTH, Tyler -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]