Sed: Deleting all content matching a pattern
Posted
by Svish
on Super User
See other posts from Super User
or by Svish
Published on 2010-04-07T14:04:16Z
Indexed on
2010/04/07
14:13 UTC
Read the original article
Hit count: 200
I have some plist files on mac os x that I would like to shrink. They have a lot of <dict>
with <key>
and values. One of these keys is a thumbnail which has a <data>
value with base64 encoded binary (I think). I would like to remove this key and value.
I was thinking this could maybe be done by sed, but I don't really know how to use it and it seems like sed only works on a line-by-line basis?
Either way I was hoping someone could help me out. In the file I would like to delete everything that matches the following pattern or something close to that:
<key>Thumbnail<\/key>[^<]*<\/data>
In the file it looks like this:
// Other keys and values
<key>Thumbnail</key>
<data>
TU0AKgAAOEi25Pqx3/ip2fak0vOdzPCVxu2RweuPv+mLu+mIt+aGtuaEtOSB
...
dCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA=
</data>
// Other keys and values
Anyone know how I could do this? Also, if there are any better tools that I can use in the terminal to do this, I would like to know about that as well :)
© Super User or respective owner