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.
Frage
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
Lösung
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.
Andere Tipps
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