String search and print next all lines in one line until blank line

Dear all

I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under.

i/p file:

A1/EXT "BSCABD1_21233G1" 757 130823   1157
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT

MO                RSITE            CLASS
RXOCF-493         ABD193+          1

EXTERNAL ALARM
HIGH TEMPERATURE
BOTH AC FAULTY

A1/EXT "BSCABD1_21233G1" 866 130823   1355
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT

MO                RSITE            CLASS
RXOCF-170         ABD170           1

EXTERNAL ALARM
 AC FAULTY

op file:(2 line)

"BSCABD1_21233G1" 757 130823   1157 RXOCF-493       ABD193+  HIGH TEMPERATURE BOTH AC FAULTY

"BSCABD1_21233G1" 866 130823   1355 RXOCF-170         ABD170 AC FAULTY

Thanks in advance.

Regards
Jaydeep Sadaria

Try something like:

awk 'sub("A1/EXT ",x){ p=$0 } /MO/{getline; p=p OFS $1 OFS $2} /EXTERNAL ALARM/{while(getline && NF) p=p OFS $0; print p}' file

Or

awk '/A1\/EXT/{ p=$2 OFS $3 OFS $4 OFS $5 } /MO/{p=p OFS $4 OFS $5} /EXTERNAL ALARM/{$1=$2=x; p=p OFS $0; print p}' RS= file

otherwise, what is the "special string" ?

1 Like

Second code is working.....

Hi All,

Please help with the following. From the following:

oats1oob 12651 12598  5 Aug21 ?        03:28:48 /apps/ts1oob/product/fmw11gR1/jrockit-jdk1.6.0_37/bin/java -jrockit -Xms768m -Xmx1536m -Dweblogic.Name=ts1oob_domain_AdminServer -Djava.security.policy=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server/lib/weblogic.policy -Xverify:none -da -Dplatform.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3 -Dwls.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server -Dweblogic.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server -Dcommon.components.home=/apps/ts1oob/product/fmw11gR1/oracle_common -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain -Djrockit.optfile=/apps/ts1oob/product/fmw11gR1/oracle_common/modules/oracle.jrf_11.1.1/jrocket_optfile.txt -Doracle.server.config.dir=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig/servers/ts1oob_domain_AdminServer -Doracle.domain.config.dir=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig -Digf.arisidbeans.carmlloc=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig/carml -Digf.arisidstack.home=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig/arisidprovider -Doracle.security.jps.config=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig/jps-config.xml -Doracle.deployed.app.dir=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/servers/ts1oob_domain_AdminServer/tmp/_WL_user -Doracle.deployed.app.ext=/- -Dweblogic.alternateTypesDirectory=/apps/ts1oob/product/fmw11gR1/oracle_common/modules/oracle.ossoiap_11.1.1,/apps/ts1oob/product/fmw11gR1/oracle_common/modules/oracle.oamprovider_11.1.1 -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler|oracle.bpm.io.fs.protocol -Dweblogic.jdbc.remoteEnabled=false -da:org.apache.xmlbeans... -Dsoa.archives.dir=/apps/ts1oob/product/fmw11gR1/Oracle_SOA1/soa -Dsoa.oracle.home=/apps/ts1oob/product/fmw11gR1/Oracle_SOA1 -Dsoa.instance.home=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain -Dtangosol.coherence.clusterport=5656 -Dtangosol.coherence.wka1=c3-a1-oa2-ipts-144 -Dtangosol.coherence.wka2=c3-a1-oa2-ipts-145 -Dtangosol.coherence.wka3=c3-a2-oa2-ipts-144 -Dtangosol.coherence.wka4=c3-a2-oa2-ipts-145 -Dtangosol.coherence.localhost=c3-a1-oa2-ipts-144 -Dtangosol.coherence.localport=9099 -Dtangosol.coherence.wka1.port=9099 -Dtangosol.coherence.wka2.port=9099 -Dtangosol.coherence.wka3.port=9099 -Dtangosol.coherence.wka4.port=9099 -Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server/lib/DemoTrust.jks -Dem.oracle.home=/apps/ts1oob/product/fmw11gR1/oracle_common -Djava.awt.headless=true -Dums.oracle.home=/apps/ts1oob/product/fmw11gR1/Oracle_SOA1 -Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=/apps/ts1oob/product/fmw11gR1/patch_wls1036/profiles/default/sysext_manifest_classpath -Xverify:none -da -Dplatform.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3 -Dwls.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server -Dweblogic.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server -Dcommon.components.home=/apps/ts1oob/product/fmw11gR1/oracle_common -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain -Djrockit.optfile=/apps/ts1oob/product/fmw11gR1/oracle_common/modules/oracle.jrf_11.1.1/jrocket_optfile.txt -Doracle.server.config.dir=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig/servers/ts1oob_domain_AdminServer -Doracle.domain.config.dir=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig -Digf.arisidbeans.carmlloc=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain/config/fmwconfig/carml -Digf.arisi

I need to get the output as follows:

-Dweblogic.home=/apps/ts1oob/product/fmw11gR1/wlserver_10.3/server
-Dsoa.instance.home=/apps/ts1oob/admin/ts1oob_domain/aserver/ts1oob_domain
..
..

All the *.home=<<PATH>> Information is required.
Let me know if you can get it.

Regards
Smarlaku

@smarlaku, please start a new thread for this...

Dear all

one more of similir proble. i used below code but it does not give complete result to me.

awk '/A1\/EXT/{ p=$2 OFS $3 OFS $4 OFS $5 } /EXTERNAL ALARM/{$1=$2=x; p=p OFS $0; print p}' RS = i/pfile

-- this give only first line op.(*** ALARM 584 A1/EXT "BSCABD1_21233G1"U 130908 0120)

i/p file:

*** ALARM 584 A1/EXT "BSCABD1_21233G1"U 130908 0120
EXTERNAL ALARM

AP    APNAME         NODE      NODENAME
 1    AP080428645C   B         AP080428645B

AMAPP
FIRE
MANISFAIL


DEV
EXAL-1-26

output needed:(IN ONE LINE)

*** ALARM 584 A1/EXT "BSCABD1_21233G1"U 130908 0120 AMAZONEPP FIRE MANIS FAIL

Guide for same.

Regards
jaydeep

sed -n '/pattern/,/^$/p' <FIELNAME>
 

This wil print from the pattern to the empty line.

Dear all

Kindly suggest for below. Needed op in one line.

awk '/A1\/EXT/{ p=$2 OFS $3 OFS $4 OFS $5 } /EXTERNAL ALARM/{$1=$2=x; p=p OFS $0; print p}' RS = i/pfile
-- this give only first line op.(*** ALARM 584 A1/EXT "BSCABD1_21233G1"U 130908 0120)

i/p file:

*** ALARM 584 A1/EXT "BSCABD1_21233G1"U 130908 0120
EXTERNAL ALARM

AP    APNAME         NODE      NODENAME
 1    AP080428645C   B         AP080428645B

AMAPP
FIRE
MANISFAIL


DEV
EXAL-1-26

output:neededIN ONE LINE)

*** ALARM 584 A1/EXT "BSCABD1_21233G1"U 130908 0120 AMAZONEPP FIRE MANIS FAIL