Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
My file content is like this :
PIN (P1) {
a1 : p9;
a2: q9
a3: t9
}PIN ( P2) {
aw: oo;
aq:op;
ac:ry;
}PIN (P5) {
am : jk;
al: lo;
as : ll;
}PIN (4) {
as : ii;
ad: l;
sw:ll:
}I want to remove the First three Blocks
So that my resultant file should bePIN (4) {
as : ii;
ad: l;
sw:ll:
}I am using
This sed
sed '/PIN1/,/PIN5/d' fileBut it is not matching the end of the Block with PIN Group PIN5
and printing this content
am : jk;
al: lo;
as : ll;
}PIN (4) {
as : ii;
ad: l;
sw:ll:
}How to match the PIN5 and the end of the Block }
Thanks
Neha

sed is not appropriate here. use awk
# awk 'BEGIN{RS=""}NR==4' file PIN (4) { as : ii; ad: l; sw:ll: }

Somehow This is not fullfilling the requirement which I need
Actually the file is very big and the subset of my file isPIN (P1) {
a1 : p9;
a2: q9
a3: t9
}PIN ( P2) {
aw: oo;
aq:op;
ac:ry;
}PIN (P5) {
am : jk;
al: lo;
as : ll;
}PIN (4) {
as : ii;
ad: l;
sw:ll:
}The script should match pattern P1 and P5 and it should remove all the Blocks related to that but the rest of the file content it should not touch

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |