Sed position specific replace

I'm drawing a blank on how to use sed to replace selectively based on position in the string (vs nth occurence):

hello.|there.|how.|are.|you.|

I want the period removed in the 3rd item (as defined by the pipe delimiter) if a period is present. So the result in this case would be:

hello.|there.|how|are.you.|

I have a feeling the solution might be embarrassing, but don't let that be a deturrent :slight_smile:

Thanks in advance,
Al

Try:

sed 's/\.|/|/3' file

This will remove the third occurrence.

But you want the period removed in the third field if it exists, so this may be more what you require:

awk -F\| '{sub(/\.$/,x,$3)}1' OFS=\| file

Thanks very much, the awk gig did the trick!