I'm new to sed
and I can't manage to use it to remove all ';' characters in comments of C++ files, ie lines starting or containing the string "//" (I already convert "/* ... */" comments to "// ..." comments).
For example :
// lorem; ipsum ; test
int a; // 1 ; 2 ; 3 ;
And I want to have :
// lorem ipsum test
int a; // 1 2 3
For any comment in my C++ files.
********* EDIT *********
Here is a solution with SED in two steps. A solution with AWK is also available in answers.
- Put all comments on a new line :
sed 's/\/\//\n\/\//g'
- Remove ';' only on lines starting by "//" :
sed '/^\/\// s/;//g'