管输出到两个不同的命令 [英] Pipe output to two different commands

查看:95
本文介绍了管输出到两个不同的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
   OSX / Linux的?管到两个过程

有没有办法通过管道从一个命令输出到其他两个命令的输入,同时运行呢?

Is there a way to pipe the output from one command into the input of two other commands, running them simultaneously?

事情是这样的:

$ echo 'test' |(cat) |(cat)
test
test

我想这样做的原因是,我有一个从USB设备SDR接收FM广播信号的节目,并输出音频作为原始PCM数据(如一个.wav文件,但没有头。)由于信号不是音乐,但POCSAG寻呼机数据,我要管到一个去codeR程序恢复寻呼机文本。不过我也想听听信号,所以我知道的数据是进来或没有。 (否则,我不能告诉,如果DE codeR被损坏或只是没有数据正在播出。)所以,以及数据管道到寻呼机德codeR,我还需要管道相同的数据来在播放命令。

目前我只知道怎么做的 - 它要么管到去codeR,默默地读取数据,或管道它播放键,听到它没有看到任何德codeD文本。

Currently I only know how to do one - either pipe it to the decoder and read the data in silence, or pipe it to play and hear it without seeing any decoded text.

可我怎么管相同的数据到两个命令,这样我就可以读课文,并听到声音?

How can I pipe the same data to both commands, so I can read the text and hear the audio?

我不能使用 T恤,因为它只是重复的数据写入到一个文件,但我需要处理实时的数据。

I can't use tee as it only writes the duplicated data to a file, but I need to process the data in real-time.

推荐答案

它应该,如果你同时使用 T恤是确定 mkfifo子

It should be ok if you use both tee and mkfifo.

mkfifo pipe
cat pipe | (command 1) &
echo 'test' | tee pipe | (command 2)

这篇关于管输出到两个不同的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆