I have a text file with thousands of lines as below
`DEFINE OBJECT('OBJECT.TOPIC') +
* ALTDATE(2015-09-22) +
* ALTTIME(00.56.38) +
DESCR('topic object') +
GET(ENABLED) +
PUT(ENABLED) +
PROPCTL(COMPAT) +
TARGTYPE(TOPIC) +
REPLACE
DEFINE OBJECT('OBJECT1') +
* CRDATE(2015-09-22) +
* CRTIME(00.56.38) +
* CURDEPTH(0) +
CUSTOM(' ') +
DESCR('TEST') +
DISTL(NO) +
PROCESS(' ') +
SHARE +
USAGE(NORMAL) +
REPLACE
DEFINE OBJECT('OBJECT2') +
* ALTDATE(2015-09-22) +
* ALTTIME(00.56.38) +
* CURDEPTH(0) +
CUSTOM(' ') +
DESCR('TEST') +
DISTL(NO) +
PROCESS(' ') +
SHARE +
USAGE(NORMAL) +
REPLACE
DEFINE OBJECT('TCOBJECT1') +
* CRDATE(2015-09-22) +
* CRTIME(00.56.38) +
* CURDEPTH(0) +
CUSTOM(' ') +
DESCR('TEST') +
DISTL(NO) +
PROCESS(' ') +
SHARE +
USAGE(NORMAL) +
REPLACE
SET RECORD +
PROFILE('OBJECT2') +
GROUP('user1') +
AUTHADD(change,delete,display,alter)
SET RECORD +
PROFILE('TCOBJECT1') +
GROUP('user3') +
AUTHADD(change,delete,display,alter)
SET RECORD +
PROFILE('OBJECT1') +
GROUP('user1') +
AUTHADD(change,delete,display,alter)
SET RECORD +
PROFILE('OBJECT1') +
GROUP('user2') +
AUTHADD(change,delete,display,alter)
SET RECORD +
PROFILE('OBJECT1') +
GROUP('user3') +
AUTHADD(change,delete,display,alter)`
Now, i want to get the blocks containing matching the pattern OBJECT1.
`DEFINE OBJECT('OBJECT1') +
* CRDATE(2015-09-22) +
* CRTIME(00.56.38) +
* CURDEPTH(0) +
CUSTOM(' ') +
DESCR('TEST') +
DISTL(NO) +
PROCESS(' ') +
SHARE +
USAGE(NORMAL) +
REPLACE
SET RECORD +
PROFILE('OBJECT1') +
GROUP('user1') +
AUTHADD(change,delete,display,alter)
SET RECORD +
PROFILE('OBJECT1') +
GROUP('user2') +
AUTHADD(change,delete,display,alter)
SET RECORD +
PROFILE('OBJECT1') +
GROUP('user3') +
AUTHADD(change,delete,display,alter)`
I have tried with awk and sed to get atleast the first part. but it's not stopping after the first match of pattern2. I am running these commands just to get the first block atleast..
awk '/OBJECT1/ {p=1}; p; $0=="REPLACE" {p=0}' objlist.txt > obj1list.txt
awk '$0=="OBJECT1" {p=1}; p; $0=="REPLACE" {p=0}' objlist.txt > obj1list.txt
cat objlist.txt | sed -n '/OBJECT1/p;/REPLACE/q' > obj1list.txt
But these dont work.Please help
As per the suggested answer, i am using awk -vRS="[^+]\n" 'BEGIN{printf "`"}/\/{printf $0 RT}' and getting the required output. However now i want to remove the block containing user2 and user3 from the output obtained by using the above command.