Então, se eu digitar o comando
$ gzip --version | head -n1
tudo corre conforme o esperado. Mas se eu tentar o mesmo com o bzip2:
$ bzip2 --version | head -n1
Eu recebo muitas linhas e tenho que pressionar Ctrl - C para finalizar.
O que está acontecendo aqui?
EDITAR:
As linhas impressas por
$ bzip2 --version | head -n1
bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010.
Copyright (C) 1996-2010 by Julian Seward.
This program is free software; you can redistribute it and/or modify
it under the terms set out in the LICENSE file, which is included
in the bzip2-1.0.6 source distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
LICENSE file for more details.
e eu tenho que pressionar Ctrl - C para continuar.
Se eu omitir o pipe, recebo
$ bzip2 --version
bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010.
Copyright (C) 1996-2010 by Julian Seward.
This program is free software; you can redistribute it and/or modify
it under the terms set out in the LICENSE file, which is included
in the bzip2-1.0.6 source distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
LICENSE file for more details.
bzip2: I won't write compressed data to a terminal.
bzip2: For help, type: 'bzip2 --help'.
Se eu mescle stdout com stderr como @devnull sais, ele exibirá bem as linhas, mas eu preciso pressionar Ctrl - C . Eu tentei
$ gcc 2>&1 | head -n1
e funciona bem, então acho que ainda falta algo no comando bzip2
.
EDIT 2:
Eu resolvi o problema com o seguinte comando:
$ bzip2 --version 2>&1 < /dev/null | head -n1
Mas ainda não entendi o problema.