从重定向文件输出二进制输出到stdout [英] Redirect binary output from file output to stdout

查看:374
本文介绍了从重定向文件输出二进制输出到stdout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个专有的二进制文件,固执地接受两个文件作为参数,首先作为输入和第二作为输出。我想


  1. 打造的第一个参数W / O创建一个临时文件

  2. 请二进制写,而不是到stdout一个输出文件(第二个参数)

我解决了第一个问题与≤(...),但不知道第二个参数

我写了下面的脚本看起来像做一切如预期:

 文件1 = $ 1
FILE2 = $ 16#检查该文件存在,其他的东西mkfifo子myfifoThatBinary≤(...)myfifo&放大器;猫myfifo

为二进制的第一个参数是它建立的第一个``文件''组合bash命令。第二个参数是命名管道的二进制必须写。因为写FIFO模块这一切都被发送到后台。最后,我打印命名管道的输出到标准输出,根据需要。

是否有可能提高该命令?任何隐藏的注意事项?我有非常大的文件工作(数十万的文本行),并希望能确定我错过什么。


解决方案

  ThatBinary≤(...)的/ dev /标准输出

I have a proprietary binary which stubbornly accepts two files as argument, first as input and second as output. I would like to

  1. build the first argument w/o creating a temporary file
  2. make binary write to stdout instead of a output file (second argument)

I solved the first issue with <(...) but not sure about the second argument.

I wrote a following script which looks like does everything as expected:

FILE1=$1
FILE2=$2

# checking that the files exist and other stuff

mkfifo myfifo

ThatBinary <( ... ) myfifo &

cat myfifo

The first argument for the binary is a combined Bash command which builds the first ``file''. The second argument is the named pipe to which the binary must write. All this is sent to background since writing to fifo blocks. Finally I print the named pipe's output to the stdout, as desired.

Is it possible to improve this command? Any hidden caveats? I am working with very large files (hundreds of thousands of text lines) and would love to be sure I miss nothing.

解决方案

ThatBinary <(...) /dev/stdout

这篇关于从重定向文件输出二进制输出到stdout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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