문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top