Please help on grepping

Hi All,
I have a log file and I want to parse the logfile with a script.A sample text is shown below:

I would grep on "return code " on this file. Any idea how the lines above and below the grep patterns could also be extracted.

Thanks!
nua7

The runLoggingInstall return code is 0
(Jul 15, 2008 2:54:33 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (startTomcatLog)
(Jul 15, 2008 2:54:35 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Wait Product Action (waitTomcatStartLog)
(Jul 15, 2008 2:55:37 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (logserver_actexec36)
(Jul 15, 2008 2:55:39 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Copy File Ex (copyfilesexdasds37)
(Jul 15, 2008 2:55:39 PM), Config, com.avaya.coreservice.icf.product.actions.CopyFileEx, msg1, CopyFileEx Config Arch : /opt/Avaya/CCR/_avpd/_arch/4.1.0/_conf.jar
(Jul 15, 2008 2:55:43 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Copy File Ex (copydhostfiles38)
(Jul 15, 2008 2:55:43 PM), Config, com.avaya.coreservice.icf.product.actions.CopyFileEx, msg1, CopyFileEx Config Arch : /opt/Avaya/CCR/_avpd/_arch/4.1.0/_conf.jar
(Jul 15, 2008 2:55:47 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (setupjboss)
The jboss unzip return code is 1
JBOSS_HOME: /opt/coreservices/jboss-4.0.3SP1
The jboss chown return code is 0
(Jul 15, 2008 2:55:53 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (uninstalljboss)
(Jul 15, 2008 2:55:55 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Files (copy_usersync)
(Jul 15, 2008 2:55:56 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (install_sync_engine

If you have GNU grep:

grep -A1 -B1 'return code' logilfe

Hey thanks a lot!! It's working like a charm!

The following solution (albeit not pretty) relies on substituting characters and temporarily removing new-line characters so as to facilitate the grep command. Once the grep is executed, then the data is re-expanded.

> cat logfile | sed "s/^The/~The/" | tr "\n" "+" | tr "~" "\n" | grep "return code is 1" | tr "+" "\n"
The jboss unzip return code is 1
JBOSS_HOME: /opt/coreservices/jboss-4.0.3SP1
> cat logfile | sed "s/^The/~The/" | tr "\n" "+" | tr "~" "\n" | grep "return code is 0" | tr "+" "\n"
The runLoggingInstall return code is 0
(Jul 15, 2008 2:54:33 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (startTomcatLog)
(Jul 15, 2008 2:54:35 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Wait Product Action (waitTomcatStartLog)
(Jul 15, 2008 2:55:37 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (logserver_actexec36)
(Jul 15, 2008 2:55:39 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Copy File Ex (copyfilesexdasds37)
(Jul 15, 2008 2:55:39 PM), Config, com.avaya.coreservice.icf.product.actions.CopyFileEx, msg1, CopyFileEx Config Arch : /opt/Avaya/CCR/_avpd/_arch/4.1.0/_conf.jar
(Jul 15, 2008 2:55:43 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Copy File Ex (copydhostfiles38)
(Jul 15, 2008 2:55:43 PM), Config, com.avaya.coreservice.icf.product.actions.CopyFileEx, msg1, CopyFileEx Config Arch : /opt/Avaya/CCR/_avpd/_arch/4.1.0/_conf.jar
(Jul 15, 2008 2:55:47 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (setupjboss)

The jboss chown return code is 0
(Jul 15, 2008 2:55:53 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (uninstalljboss)
(Jul 15, 2008 2:55:55 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Files (copy_usersync)
(Jul 15, 2008 2:55:56 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (install_sync_engine