Thanks actually that soultion actually worked .
I am having another issue with my awk script
Contents of my file is like this
file
AND (P1) {
no : and ;
mo : band ;
co : land ;
}
OR (P2) {
no : sand ;
cling : dad ;
Fiend : salt ;
}
NAND (P3)
no : sat ;
to : jat;
pi : tad;
}
What I need to do I need to search the patterns AND (P1) and OR (P2) and then delete all the contents of this Block and insert the content from another file - file2 ( between P1 and P2 ) in this location.
What I am doing ; I am inserting the code first
awk '{ if($0 ~ /P1/) {set=1; next}; if( $0 ~ /P2/) {set = 0}; if (set ) { print }}' file2 | awk '/AND (P1)/{f=1}f && /}/{print; system("cat $1");f=0;next}1' file > newfile
file2 content
############
P1
AND is the the band
land is the and
P2
#############
After this To delete the blocks I could use
sed '/AND/,/OR/d' file
I am having two issues here
1. The code will be inserted after the AND (P1) Block I want the code to be inserted before AND (P1) Block so that I can delete the respective blocks after that
2. By using the command
sed '/AND/,/OR/d' file
I will delete not full contents
It will delete only these entities
AND (P1) {
no : and ;
mo : band ;
co : land ;
}
OR (P2) {
Need some advice in this regards
Shalini