Unwrapping a java manifest file fin bash

大城市里の小女人 提交于 2019-12-25 07:40:49

问题


In Java, META-INF/MANIFEST.MF files have a maximum line length. Beyond that, an automatic line break is inserted, signaled by a space at the beginning of the next line, like so:

Manifest-Version: 1.0
Export-Package: com.google.common.net;uses:="com.google.common.base,ja
 vax.annotation[file continues]
Bundle-Name: Guava: Google Core Libraries for Java

Unfortunately, this makes it painful to grep and sed in bash.

How would you go about unwrapping it, using bash, into this?

Manifest-Version: 1.0
Export-Package: com.google.common.net;uses:="com.google.common.base,javax.annotation[file continues]
Bundle-Name: Guava: Google Core Libraries for Java

I'd try sed, but it works only on a per line basis, and I can't get tr to work properly either.

Thanks!

EDIT: related question


回答1:


Try this Perl one-liner:

$ perl -0777 -wpe 's/\n //g' MANIFEST.MF

It removes every instance of a line-break followed by a space.



来源:https://stackoverflow.com/questions/14235872/unwrapping-a-java-manifest-file-fin-bash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!