I need to use a bash script to delete full-line old-style
comments from a C program,
i.e., comments that begin (/*
) and end (*/
) on the same line,
with no code on the same line.
This is an example of what the C program looks like:
/* Comment 1 */
printf("It is /* Comment 2 */\n");
x = 5; /* Comment 3 */
/* Comment 4 */
/* Comment 5 */ y = 0;
/*
* Comment 6
*/
// Comment 7
But I need it to look like this:
printf("It is /* Comment 2 */\n");
x = 5; /* Comment 3 */
/* Comment 5 */ y = 0;
/*
* Comment 6
*/
// Comment 7
I do know how to delete all comments but just not sure on how to just remove certain ones.
The script should read inputs from a text file, and write outputs into another file, and all the I/O file names must be given in the command-line.
Comment 1
andComment 4
? Should it delete random comments? Is there any rhyme or reason to what you want to accomplish? – jesse_b May 22 '19 at 14:16