Hi All,
Can some one please help me how to grep the comments from "oracle" & "sybase" code. I would like to grep below type of pattern.
--
/* */
Please help.
Hi All,
Can some one please help me how to grep the comments from "oracle" & "sybase" code. I would like to grep below type of pattern.
--
/* */
Please help.
grep -E '/\*.*\*/|\-\-' file
or if you have multi-line /* */ comments:
awk '/\/\*.*\*\// || /\/\*/,/\*\//{print}/--/' file
Another one:
awk '/--/;/\/\*/{p=1};p;/\*\//{p=0}' file
Thanks a lot for your quick revert.
Is it possible to find the pattern in between some sting like below,
/*
xyz xyz
xyz xyx
*/
For eg. need to exclude evrything between starting "/" & ending "/", please advise.
This command should do the job:
awk '/--/;/\/\*/{p=1};p;/\*\//{p=0}' file
This is the output I get:
$ cat file
Tue Mar 25 23:35:00 GMT 2008
-- COMMENT Tue Mar 25 21:34:23 GMT 2008
Tue Mar 25 18:18:10 GMT 2008
/* COMMENT Mon Mar 26 15:54:13 GMT 2008 */
Mon Mar 26 13:21:40 GMT 2001
Mon Mar 26 13:21:40 GMT 2002
/*
COMMENT Mon Mar 26 13:21:40 GMT 2003
COMMENT Mon Mar 26 13:21:40 GMT 2004
*/
$
$ awk '/--/;/\/\*/{p=1};p;/\*\//{p=0}' file
-- COMMENT Tue Mar 25 21:34:23 GMT 2008
/* COMMENT Mon Mar 26 15:54:13 GMT 2008 */
/*
COMMENT Mon Mar 26 13:21:40 GMT 2003
COMMENT Mon Mar 26 13:21:40 GMT 2004
*/
Thanks all for your help. One last question how can I exclude the pattern searched by below code,
awk '/--/;/\/\*/{p=1};p;/\*\//{p=0}' file
Something like this?
awk '/--/{next};/\/\*/{p=1};!p;/\*\//{p=0}' file