Code_rocks Code_rocks - 3 months ago 17
Bash Question

Remove the comment out part of BTEQ file with shell script

I am new to shell script, i want to remove comment out part from BTEQ file with shell script

my BTEQ file contain

/*
***********************************************************
my comment out part start
some more content
**********************************************************
*/
select * from abc
/*****query description********************/
DELETE name from abc;
/*****query description********************/
create table name
/*****query description********************/


i want the output as below in same BTEQ

select * from abc
DELETE name from abc;
create table name


Thanks

Answer

Using perl-regular-expressions, with greedy substitution(.*?)

$ perl -p0 -e 's#/\*.*?\*/##sg' file | perl -lane "print if /\S/"
select * from abc
DELETE name from abc;
 create table name