How to ignore single or multiple lines between /* and */ while reading from a file in unix?

I have a file proc.txt:

if @debug = 1 then
   message 'Start Processing ', @procname, dateformat(now(*), 'hh:mm:ss'), @julian type info to client;
end if;
/*
execute immediate with quotes
  'insert into sys_suppdata (property, value, key_name)
  location ''' || @supp_server || '.' || @supp_db || '''' ||
  ' {select property, value, key_name
     from sys_suppdata
   where  key_name    = ''Approve_Deny_Description''
   or key_name     = ''Referral_Description'' }';
*/
-- Create SE Currency Table for Processing SE Results & Conversion
/* to prevent it from executing */

When reading this file thru shell script using the code below:

cat proc.txt | while read str
do
..
done

I want to ignore all the commented lines, whether single or multiple, i.e. between /* and */ and read all the other lines. Please suggest

sed '/\/\*/,/\*\//d' filename

Try something like this:

awk '/\/\*/{f=1} /\*\//{f=0;next} !f' proc.txt | while read str
do
  ...
done

xbin - I tried your cmd earlier to even posting here. Actually sed will not work out if /* and */ fall in the same line. So the line

/* to prevent it from executing */

will not be deleted.

Franklin52 - i gave ur cmd in a ksh script and ran. It threw below error:

a.ksh:

#!/usr/bin/ksh
awk '/\/\*/{f=1} /\*\//{f=0;next} !f' /idn/home/pmylavar/proc/submon_se_cas_detail.sql | while read str
do
  echo "str is $str"
done

o/p:

awk: syntax error near line 1
awk: bailing out near line 1

Use /usr/xpg4/bin/awk or nawk on Solaris.

1 Like

Many thanks Franklin..It works with nawk:-)