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 - 在 SIGILL 处理程序中,如何跳过有问题的指令?

linux - System.map文件中address的含义

python - 在带 wifi 的公寓中安装 python 包时出错

linux - 在 Linux 上使用 cat 连接有序文件

linux - 使用du -sh *命令时如何根据子目录的大小排序?

linux - 使用awk计算统计量

bash - ${v^^} 和 ${v@U} 的区别?

获取目录列表的 Bash 命令

linux - 安装 HTML::TreeBuilder::XPath 失败

shell - 使用cron作业和Shell脚本发送邮件