I want to delete specific two consecutive lines matching patterns from specific line from a file.
For e.g. file contents are like below.
Line1: a Line2: b Line3: c Line4: Name: 123 Line5: xyz Line6: Name: 456 Line7: abc
I want to find the lines starting from line 4, matching 1st line pattern starting with "Name: " and matching 2nd line pattern starting with whitespace and delete the two consecutive lines.
Any efficient way to do this in shell using
sed or something else?
To be a bit more clear, I want to remove signing/checksum information from the MANIFEST.MF.
Sample MANIFEST.MF like below: From the below manifest file, I want to remove the entry "Name: ". where "Name: " entry can be in one line or 2(or more) lines.
Initially my solution was like find the first "Name: " entry followed by "SHA-256-Digest: " entry and delete to the end of the file. Unfortunately this solution has a problem of removing one needed entry in the middle. For e.g. "NetBeans-Simply-Convertible: " is also being removed.
So, now I want to remove "Name: " entry if available in 1 line or entry spanned across 2 or more lines. But I should not lose entries like "NetBeans-Simply-Convertible: " while removing "Name: " entries.
Already I am removing "SHA-256-Digest: " entries with the below command on file with
sed -i "/^\SHA-256-Digest: /d" $manifest_file
SHA-256-Digest: 5FszAtfpPXcLx/6FBWbfeg6E4fwFMRozV+Q+3rReATc= ...