sed and maybe AWK

Hello
I would like to replace in a big file:

this

000000001 260   L $$aVIENNA :$$bIAEA, 1988,$$c1988.

by this

000000001 260   L $$aVIENNA :$$bIAEA,$$c1988.

As you see, the date into the second field is to be remove...
How can I do?
the patern could be this:

, 1

and

, 20

Thanks a lot

 awk -F, '{print $1 FS $3}' file
sed 's/,.*,/,/'

Hi
ok it works, but in some case I have the second filed with the title with comas...
So the sed sed 's/,.*,/,/'drop the rigth part of the title...
Exemple:

000000001 260 L $$aVIENNA :$$bIAEA, SECOND INFO, 1988,$$c1988.

sed 's/, [0-9]*,/,/'
sed 's/[^,]*,\([^,]*$\)$/\1/' infile
awk -F, '{$(NF-1)=x}sub(FS FS,FS)' OFS=, infile

Hi Aia
thanks for the exemple...
It still don't works for all the records. Look this exemple:
Where SAN DIEGO is the first field (no problem with it)
and where ACADEMIC PRESS, INC.;1989;SAN DIEGO, CALIFORNIA 92101
is the second filed...

SAN DIEGO;ACADEMIC PRESS, INC.;1989;SAN DIEGO, CALIFORNIA 92101

If I pass your script I have this:

$$aSAN DIEGO :$$bACADEMIC PRESS, INC.,$$c1989.

SAN DIEGO, CALIFORNIA 92101 is missing then...
Maybe there is a way to get just 4 digits as a date?
I try this but it do not works:

sed -i '/[0-9]\{9\} 260   L/s/, [0-9]\{4\},/,/g' biblio1.mrk_aleph_sec.dat

Thanks in advance if you have some idea.
Cheers

I'm confused by your last sample which has semicolons instead of colons as field separator. Anyway, that one might do it:

sed 's/\([;,]\)[ 0-9]*\1/\1/'

So at the beginning of your post the field separator was "," now in your SAN DIEGO sample line, the field spearator is now ";" ... what's going on ?

Could you please provide a representative input file containing all the case of line formating possible you want to filter and give us what output file sample you expect, then maybe people will be able to help

Hi
Yes the problem of this file, is this.. All the field do not have the same patern.
It's complicated.
Look this other exemple:

AMSTERDAM;NORTH-HOLLAND PUBLISHING COMPANY;1980;52 VANDERBILT AVENUE, NEW YORK, N.Y. 10017

The only item i have to remove here is the date...

so the result should be:

AMSTERDAM;NORTH-HOLLAND PUBLISHING COMPANY;;52 VANDERBILT AVENUE, NEW YORK, N.Y. 10017

There are other exemple with the date rounded with ,

like this:

PARIS : OECD, 1989

or

MADRID : JUNTA DE ENERGIA NUCLEAR, 1965

Thanks

And you think that wasn't worth mentioning in the first place ??

Did you try my last suggestion ? It works with that one.

I don't see any date rounded with colons here, only prefixed. Do you mean the date field can also be the last one ?

Hi
the last suggestion works fine but if I have this string:

SAN DIEGO :ACADEMIC PRESS, INC.;1989;UNIVERSITY CAFILORNIA

it don't works.
because the output of the suggestion is this:

SAN DIEGO :ACADEMIC PRESS, INC.,

So all the text after the date is dropped too.

I check the whole file and there are 3 case:

1 (this case is ok with your seggestion

AMSTERDAM :NORTH-HOLLAND,1989
Needed result:
AMSTERDAM :NORTH-HOLLAND,

2 This case do not works because PUBLISHING COMPANY is dropped too

AMSTERDAM :NORTH-HOLLAND,1989,PUBLISHING COMPANY
Needed result:(if 2 , appear here it's not a problem)
AMSTERDAM :NORTH-HOLLAND,,PUBLISHING COMPANY

3 Same problem

AMSTERDAM :NORTH-HOLLAND;1989;PUBLISHING COMPANY
Needed result:(if 2 ; appear here it's not a problem)
 AMSTERDAM :NORTH-HOLLAND;;PUBLISHING COMPANY
 

Thanks in advance

sed 's/[;,][ ]\?[0-9]\{4\}//'

Hi

many of the records have been formatted fine, but not this one:

GAINESVILLE;INTERFERENCE CONTROL TECHNOLOGIES;1982;ROUTE 625, GAINESVILLE, VA 22065

The result expected is this:

GAINESVILLE;INTERFERENCE CONTROL TECHNOLOGIES;;ROUTE 625, GAINESVILLE, VA 22065

THanks

???
Huh:

$ echo 'SAN DIEGO :ACADEMIC PRESS, INC.;1989;UNIVERSITY CAFILORNIA' | sed 's/\([;,]\)[ 0-9]*\1/\1/'
SAN DIEGO :ACADEMIC PRESS, INC.;UNIVERSITY CAFILORNIA

Cafilornia :smiley:

Great !!!
Thanks a lot
it works FINE !!

Cheers and have a nice sunday !

Ciao