Re: Sed advice needed



Here's one way:

# Put the sample lines into a file called inline.txt
for inline in `cat inline.txt | tr -d " "` #remove spaces for cut
do
# Remove quotes
Tmp=`echo $inline | tr -d "\""`
# Break into fields...
f1=`echo $Tmp | cut -f1 -d","`
f2=`echo $Tmp | cut -f2 -d","`
f3=`echo $Tmp | cut -f3 -d","`
f4=`echo $Tmp | cut -f4 -d","`
f5=`echo $Tmp | cut -f5 -d","`
# Get data past = char form the 3rd entry in 6th field
f6=`echo $Tmp | cut -f8 -d"," | cut -f2 -d"="`
echo "\"$f1\",\"$f2\",\"$f3\",\"$f4\",\"$f5\",\"$f6\""
done

Enjoy,
Larry
----- Original Message ----- From: "Piers Kittel" <debian@xxxxxxxxxx>
To: <debian-user@xxxxxxxxxxxxxxxx>
Sent: Thursday, May 31, 2007 12:05 PM
Subject: Sed advice needed


Hello all,

I need to delete some words out of a large file containing information about packets I'm analysing. I know I can use sed to do this, but haven't really used it before, so am a bit unsure of how to do it. Two example lines are as of below:

"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?

Thanks very much for your time in advance!

Regards - Piers


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx




--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: phpmyadmin
    ... I just don't really understand what is going on as the same server will serve up other php pages, but phpmyadmin seems only able to serve html pages. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ... Trouble? ...
    (Debian-User)
  • Re: _some_ DVDs wont play
    ... the DVD makes xine crash. ... No trouble playing almost all other DVDs. ... A borrowed set of LOTR discs will play on all machines. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Sed advice needed
    ... I've been reading the man pages of ... cut and awk but I can't quite figure out how to do this. ... I'm missing the quotes around the last field. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: How do you grow brocolli?
    ... People having trouble with vz bouncing email to me should add the word ... Copyright 2006 by Maurice Eugene Heskett, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Problem with kdvi font rendering after sarge-->etch upgrade
    ... I have no trouble opening these doucments on my ... Do You Yahoo!? ... Mail has the best spam protection around ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)