how to use sed/awk to remove words with multiple pattern count

Posted by user1461112 on Stack Overflow See other posts from Stack Overflow or by user1461112
Published on 2012-06-16T21:01:37Z Indexed on 2012/06/16 21:16 UTC
Read the original article Hit count: 116

Filed under:
|

I have a file of string records where one of the fields - delimited by "," - can contain one or more "-" inside it.

The goal is to delete the field value if it contains more than two "-".

i am trying to recoup my past knowledge of sed/awk but can't make much headway

==========

info,whitepaper,Data-Centers,yes-the-6-top-problems-in-your-data-center-lane

info,whitepaper,Data-Centers,the-evolution-center

info,whitepaper,Data-Centers,the-evolution-of-lan-technology-lanner

==========

expected outcome:

info,whitepaper,Data-Centers

info,whitepaper,Data-Centers,the-evolution-center

info,whitepaper,Data-Centers

thanks

© Stack Overflow or respective owner

Related posts about sed

Related posts about awk