I'm redirecting a batch file's output into a text file and don't want blank lines between each command. I realise I could post-process with a perl one-liner, but would rather not. Is there an option somewhere to suppress these unnecessary blank lines?
Windows – How to stop the Windows command line from outputting an empty line after each command
command linewindows
Best Answer
cmd
always outputs a new line before it prints its prompt. This means that something likewill always have that blank line since
echo
prints a line break automatically. However, something likewill not have the empty line in between since above is the the trick that allows printing stuff without a trailing line break. Still, the prompt appears at the beginning of the next line.
This is presumably done to have the prompt always at the start of the line, regardless how messed-up the last command's output was. On UNIX-likes it's common to find your prompt in the middle of the line since the last command didn't print a newline.
But there doesn't seem to be a way to prevent his behavior.
You can easily pipe whatever you're doing there through
though.