i am ahving following file
thanks,
vidya...
i am ahving following file
thanks,
vidya...
There is an example on the perlop man page which is simpler:
# Delete (most) C comments.
$program =~ s {
/\* # Match the opening delimiter.
.*? # Match a minimal number of characters.
\*/ # Match the closing delimiter.
} []gsx;
is there any unix command??
i don't wana go for perl.. and in AIX perlop is not available...
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:
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:
some code; /* a comment */ some more code; /*another comment */
would become:
some code;
This works better:
awk -v RS='^Y' ' { gsub("/\*.*\*/",""); print; }'
However also doesn't handle multiple comments on a line. You could make it safer like this:
awk -v RS='^Y' ' { gsub("/\*[^*]*[^/]*\*/",""); print; }'
The only situation that does not handle well is a /* comment * like / this */, which I guess would be pretty rare.
(Incidentally, ^Y is just a randomly chosen, rarely used control character, entered using Ctrl-V Ctrl-Y.)