I would like to do some processing with ex (vim in ex/silent mode). There is however a strange behaviour if a line is empty. An extra space character is added to that line - even in binary mode. Is it possible to eliminate that?
Check out:
$ printf "a\n1st\n\n3rd\n.\n%%p\n" | ex -b | hexdump -C
00000000 31 73 74 0a 20 0a 33 72 64 0a
Note the Ex rows in printf: a for appending text, three rows, . to close append mode, %p to print everything)
a
1st
3rd
.
%p
The expected result is
00000000 31 73 74 0a 0a 33 72 64 0a
printfdoesn't seem to be where that extra space comes:exdoesn't seem to be involved either, at least used in a somewhat more "normal" way:but you are not using
exthat way. You are somehow making a kind of screen dump tostdout, which might explain the appearance of that space.Without knowing what you are actually trying to do it is hard to provide a better solution. In any case, being a full screen document-oriented program,
exis generally not suited for use in a pipe so you might want to look for a different approach.