问题
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