I would like to remove all the text between the strings /*
and */
in a file, where the strings may occur on different lines and surround a comment. For example I would like to remove the following seven lines which are contained between /*
and */
:
/* "CyIHTAlgorithm.pyx":81
* @cython.wraparound(False)
* @cython.cdivision(True)
* cdef inline object IHTReconstruction2D(fType_t[:,:] data, # <<<<<<<<<<<<<<
* fType_t[:,:] residualFID,
* fType_t[:,:] CS_spectrum,
*/
I have managed to do this using sed where the strings occur on the same line:
sed -i.bak 's/\(\/\*\).*\(\*\/\)/\1\2/' test.txt
but I'm not sure how to extend this to multiple lines in the same file:
I have also tried:
sed -i.bak '/\/\*/{:a;N;/\*\//!ba;s/.*\/\*\|\*\/.*//g}' test.txt
following the ideas here (Extract text between two strings on different lines)
This deletes the /*
at the beginning and */
but not the intervening text.