Awk or Sed help

Hi,

I have a data file with 5 columns - like this:

"20080401 09:43:08.770798 +0100s","TEST 1","R 1","A TEST","Nov 27 2007","1"
"20080401 09:43:08.770798 +0100s","THIS IS A TEST","R 2","B TEST","Nov 30 2007","10"
"20080401 09:43:08.770798 +0100s","ANOTHER TEST","R 3","B TEST","Nov 05 2007","14"

I would like to delete the last two values e.g. ,"Nov 05 2007","14"

How can I do this using sed or awk?

Many Thanks!

With sed you can something like:

sed '/$/s/,"Nov 05 2007","14"//' file

Regards

Thanks for your reply - this will not work for me as the values in the last two columns could differ.

try:

awk -F, '{print $1","$2","$3","$4}' file

Ok, try this one:

awk '
BEGIN{FS=OFS=","}
s{print s}
{printf("%s,%s,%s,%s", $1,$2,$3,$4);s=","$5 ","$6}
END{print ""} 
' file

Edit:

Maybe I'm missing something, but i assumed you want to delete the 2 last columns of the last line.
If you want to delete the last 2 columns on every line you can use the code of unilover.

Regards

Thank you, this is good, however, two questions.

I have added this to my sed script but I get this error when I run sed -f (script) - "sed: command garbled: awk -F, '{print $1","$2","$3","$4}'"

Also, when I run your command I get ,,, (three commas) at the end of each line.

Well, what I wrote IS a complete UNIX-Command which, obvously and naturally, SHOULD be executed either from a Command-Line or in a SHELL-SCRIPT!!!

as for the "three-commas", you should definitely be messing up something or your data-file is not exactly as you'd said is!?!?!

Sorry my mistake it is working.