I am trying to remove comments from a file which may be in any part of a line and span multiple lines.
struct my_struct{
field1;
field2; /** comment 1
*/ field3;
/* comment 2 */
} struct_name;
I need to get
struct my_struct{
field1;
field2;
field3;
} struct_name;
I tried using
grep -o '[^/*]*[^*/]'
to remove any text between matching /* and */, but it is eliminating the comment symbols but not the text in between. What is the correct way? If there is another way using 'sed', it would be nice to know that too.