如何过滤运行程序的输出?

时间:2013-03-03 20:38:38

标签: bash pipe

我有这个bash命令:

find $DIR -type f -maxdepth 1 -name '*.mkv' | { 
    while read filename ; do 
        mkvmerge -o "${OUTDIR}/${filename}" "${filename}" "${filename%.mkv}.mka" "${filename%.mkv}.ass"  
    done 
}

这给了我以下输出:

mkvmerge v5.8.0 ('No Sleep / Pillow') built on Mar  3 2013 21:06:19
'./file.mkv': Using the demultiplexer for the format 'Matroska'.
'./file.mka': Using the demultiplexer for the format 'Matroska'.
'./file.ass': Using the demultiplexer for the format 'SSA/ASS subtitles'.
'./file.mkv' track 0: Using the output module for the format 'AVC/h.264'.
'./file.mkv' track 1: Using the output module for the format 'FLAC'.
'./file.mka' track 0: Using the output module for the format 'AC3'.
'./file.ass' track 0: Using the output module for the format 'text subtitles'.
The file './out//./file.mkv' has been opened for writing.
Progress: 9%

只有进度线刷新。我想在“进步”线之前摆脱那些线。首先我想我最后可以添加它:| grep "Progress"但它不起作用。是否有任何解决方案来格式化正在运行的程序的输出?我知道bar实用程序几乎可以以相同的方式生成很好的进度条:

bar example

我尝试2> log1> log - 没有任何作用。

2 个答案:

答案 0 :(得分:1)

mkvmerge -o "$OUTDIR/$filename" "$filename" "${filename%.mkv}.mka" "${filename%.mkv}.ass"|(sed -n /^The/q;cat)

答案 1 :(得分:0)

mkvmerge有一个安静模式,试试吧:

  

$ mkvmerge -q