Sponsored Content
Full Discussion: help me out...
Top Forums Shell Programming and Scripting help me out... Post 302227292 by Annihilannic on Thursday 21st of August 2008 02:48:17 AM
Old 08-21-2008
Without perl multi-line regex capability I don't think you'll be able to simplify it too much... unless you change RS in awk maybe? I might try that next. Here is an awk solution, but as you can see it's not short:

Code:
awk '
        /\/\*.*\*\// { gsub("/\*.*\*/",""); print; next }
        /\/\*/ { gsub("\/\*.*",""); print; incomment=1; next }
        incomment && /\*\// { gsub(".*\*\/",""); incomment=0; print }
        incomment { next }
'

It does not work for situations where there are multiple comments on a line, e.g. the following:

Code:
 some code; /* a comment */ some more code; /*another comment */

would become:

Code:
 some code;

 
All times are GMT -4. The time now is 04:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy