-1

the code is like this:

/* a comment line in a C program */
printf("It is /* NOT a comment line */\n");
x = 5; /* This is an assignment, not a comment line */
[TAB][SPACE] /* another empty comment line here */

And the expected output is like this:

printf("It is /* NOT a comment line */\n");
x = 5; /* This is an assignment, not a comment line */
Cool
  • 39
  • 4
  • You have mentioned: `x = 5; /* This is an assignment, not a comment line */`. In `c` everything, and I mean really everything, that looks like `/* some text anywhere in the code */` is a comment and nothing else than a comment. Or do you just want to delete comments in those lines no code exists? – John Goofy May 16 '17 at 08:01

1 Answers1

1

To remove the line and print the output to standard out:

sed '/pattern to match/d' ./infile

To directly modify the file (and create a backup):

sed -i.bak '/pattern to match/d' ./infile
  • And what is the pattern And i tried this: $ sed '/^\/\//d;/^\/\*$/,/^\*\//d' infile.cpp – Cool May 15 '17 at 11:56