1

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

4

2 に答える 2

2

このPerlワンライナーを試してみてください:

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

改行の後にスペースが続くすべてのインスタンスを削除します。

于 2013-01-09T13:24:00.323 に答える
0

Use -z to separate by lines with null, -i to edit in-place

sed -i -z 's:\n ::g' MANIFEST.MF

My manifests have CRs so

sed -i -z -r 's:\r?\n ::g' MANIFEST.MF
于 2020-11-25T15:23:58.920 に答える