linux - bzip 命令不适用于 "tee -a"

标签 linux bash shell unix bzip2

我想使用 tee 命令将 bzip 命令的 stdop 重定向到日志文件,但它不起作用并且在 tee 命令中为“-a”给出错误。请查看下面的错误,

> bzip2 file -c 1> tee -a logfile

bzip2: Bad flag `-a'
bzip2, a block-sorting file compressor.  Version 1.0.5, 10-Dec-2007.

   usage: bzip2 [flags and input files in any order]

   -h --help           print this message
   -d --decompress     force decompression
   -z --compress       force compression
   -k --keep           keep (don't delete) input files
   -f --force          overwrite existing output files
   -t --test           test compressed file integrity
   -c --stdout         output to standard out
   -q --quiet          suppress noncritical error messages
   -v --verbose        be verbose (a 2nd -v gives more)
   -L --license        display software version & license
   -V --version        display software version & license
   -s --small          use less memory (at most 2500k)
   -1 .. -9            set block size to 100k .. 900k
   --fast              alias for -1
   --best              alias for -9

   If invoked as `bzip2', default action is to compress.
              as `bunzip2',  default action is to decompress.
              as `bzcat', default action is to decompress to stdout.

   If no file names are given, bzip2 compresses or decompresses
   from standard input to standard output.  You can combine
   short flags, so `-v -4' means the same as -v4 or -4v, &c.

问题是什么?为什么 bzip 正在考虑 tee 命令的 '-a' 标志。

最佳答案

尝试:

bzip2 -c file | tee -a logfile

|(管道)将左侧命令的标准输出重定向到右侧命令的标准输入。

-c 是 bzip2 的一个选项,表示 Compress or decompress to standard output.。参见 man bzip2

关于linux - bzip 命令不适用于 "tee -a",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33297845/

相关文章:

linux - 如何使用 du 从 stdin 获取路径并计算总大小?

linux - 如何在内核模块代码中添加轮询功能?

linux - 使用 sed 根据正则表达式结果替换部分文本

bash - 如何从其他目录执行go get?

java - 从 shell 脚本调用耳朵中存在的 Java 类

python - 为什么 signal.SIGALRM 在 Windows 上的 Python 中不起作用?

python执行linux shell,只返回一行

Bash 管道命令输出到总和循环

php - 如何在 Mac OS X 上将 PHP shell 脚本作为 Automator 操作执行

mysql - 在终端中使用 mysql 来抑制警告消息,但密码是用 bash 脚本编写的