I m trying to change some characters in a file, like this:
//this is a thest of how this works
#include <stdio.h>
int main()
{
// declare some variables here
int num1 = 4;
float num2 = 3.5;
// print the result
printf("The result is %f\n", num1 * num2); // this does it
/* does it work? */
return 0;
}
I want to change all the // character for commenting in c++ to the c comment characters /* */ making the file then look like this:
/* This is a test of how this works */
#include <stdio.h>
/*this is a thest of how this works */
#include <stdio.h>
int main()
{
/* declare some variables here */
int num1 = 4;
float num2 = 3.5;
/* print the result */
printf("The result is %f\n", num1 * num2); /* this does it */
/* does it work? */ */
return 0;
}
I do not know much bash at all and this is what i came up with sed 's/////* *//g' myprog.c it did not work, what am i doing wrong or what do i need to do to make these changes? Im trying to make it a one line command
sed
is the wrong tool for this job but good luck anyway... – don_crissti Oct 08 '18 at 14:29