$ cat testf
line one
sec begin
id=25
details=ax
status=y
sec end
sec begin
id=26
details=ay
status=n
sec end
sec begin
id=28
details=am
status=n
sec end
last line
I had to delete the para which is having "id=26", this is what I did
$ sed '/id=26/{N;N;N;d;}' testf
o/p:
line one
sec begin
id=25
details=ax
status=y
sec end
sec begin
sec begin
id=28
details=am
status=n
sec end
last line
How can I delete the whole paragraph (from "sec begin" to "sec end") where "id=26" is present. i.e.
required output:
line one
sec begin
id=25
details=ax
status=y
sec end
sec begin
id=28
details=am
status=n
sec end
last line
But I am unable to supply a variable with double quote in the sed solution above.
e.g.
$ var=26
$ sed ":_
/begin/,/end/{
/end/!{
$!{
N
b_
}
}
/id=$var/d;
}" testf
The above is not working. How can I supply a part of the pattern as variable, please help.