char str[MAX]; char str [MAX];
char *ptr; char * ptr;
int CASE; int CASE;
double temp; double temp;
Output should be:
char str[MAX];
char *ptr;
int CASE;
double temp;
How can i do this with awk,sed,perl?
char str[MAX]; char str [MAX];
char *ptr; char * ptr;
int CASE; int CASE;
double temp; double temp;
Output should be:
char str[MAX];
char *ptr;
int CASE;
double temp;
How can i do this with awk,sed,perl?
perl -pe 's/;.*/;/' file
awk -F ";" '{print $1";"}' file
And with sed, just like the perl solution of bartus11:
sed 's/;.*/;/' file
It's a cpp source code.It may contain for loop
char str[MAX]; char str [MAX];
char *ptr; char * ptr;
int CASE; int CASE;
double temp; double temp;
for(int i=0;i<=10;i++){
...
}
Output should be:
char str[MAX]; char str [MAX];
char *ptr; char * ptr;
int CASE; int CASE;
double temp; double temp;
for(int i=0;i<=10;i++){
...
}
for loop would be unchanged.
awk '/{/{p=1}/}/{p=0}!p{sub(";.*",";")}1' file