本文介绍了gnuplot 和 bash 进程替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
gnuplot 是否允许 bash 进程替换?
Does gnuplot allow bash process substitution?
在 gnuplot 中我可以做到:
In gnuplot I can do:
plot "<join tmp1 tmp2" u 2:3
但我无法让它工作:
plot "<join tmp1 <(join tmp2 tmp3)" u 2:3
它应该有效,还是 gnuplot 不支持 bash 进程替换?
Should it work, or isn't bash process substitution supported in gnuplot?
以下是 3 个示例输入文件:
Here are 3 example input files:
猫 tmp1
A 1
B 2
C 3
猫 tmp2
B 3
C
D 6
猫 tmp3
A 4
B 6
C 8
D 10
E 12
推荐答案
<
后面的命令是用 popen()
执行的,它使用了 /bin/sh
(见man popen
).因此,您必须显式调用 bash
以使用进程替换:
The command following the <
is executed with popen()
, which uses /bin/sh
(see man popen
). So you must invoke bash
explicitely in order to make use of the process substitution:
plot '< exec bash -c "join tmp1 <(join tmp2 tmp3)"' using 2:3
在您使用单个替换的情况下,也可以执行以下操作:
In your case with the single substitution the following would also do:
plot '< join tmp2 tmp3 | join tmp1 -' using 2:3
这篇关于gnuplot 和 bash 进程替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!