How can I match a pattern, delete the pattern and also the next and the previous line on Solaris 10? I'm hiting the wall because Solaris does not come with GNU sed. Given the following file content:
LinearFile(3F007F106F3B, FDN, 29, 20)
LinearFile(3F007F106F40, XXX, 29, 1)
{
LinearRec(1, 12345)
}
LinearFile(3F007F106F3C, SMS, 176, 20)
LinearFile(3F007F106F4F, ECCP, 15, 10)
LinearFile(3F007F106F40, XXX, 29, 1)
{
LinearRec(1, FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
}
LinearFile(3F007F106F42, SMSP, 43, 3)
BinaryFile(3F007F106F43, SMSS, 2)
LinearRec(1, 12345)
I would like to remove the block that contain:
{
LinearRec(1, FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
}
The file would be:
LinearFile(3F007F106F3B, FDN, 29, 20)
LinearFile(3F007F106F40, XXX, 29, 1)
{
LinearRec(1, 12345)
}
LinearFile(3F007F106F3C, SMS, 176, 20)
LinearFile(3F007F106F4F, ECCP, 15, 10)
LinearFile(3F007F106F40, XXX, 29, 1)
LinearFile(3F007F106F42, SMSP, 43, 3)
BinaryFile(3F007F106F43, SMSS, 2)
LinearRec(1, 12345)
To delete the next line I issued the following:
sed -e '/LinearRec(1\,\ FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)/{n;d;}' file.txt
What about the line that matchs and the previous line?
Maybe it can be achieved by using ed or vi? Thx!
sed
?grep
andawk
are fine?