Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 没有临时文件的通信_Unix_Sh_Comm - Fatal编程技术网

Unix 没有临时文件的通信

Unix 没有临时文件的通信,unix,sh,comm,Unix,Sh,Comm,我一直在尝试编写一个命令,它接收单个单词的列表、排序、重复数据消除、使用comm将条目与字典文件进行比较,最后输出字典中没有的内容 我当前的迭代是: sort | uniq > tmp; comm -23 tmp dictionary.txt 我从上面的键盘输入,但理想情况下我想把它保存为一个.sh,这样我就可以做了 sh code.sh < wordlist.txt 是否有任何方法可以在不创建tmp文件的情况下实现相同的结果?您可以使用: 一个非常方便的用例是比较两台其他主机上

我一直在尝试编写一个命令,它接收单个单词的列表、排序、重复数据消除、使用comm将条目与字典文件进行比较,最后输出字典中没有的内容

我当前的迭代是:

sort | uniq > tmp; comm -23 tmp dictionary.txt
我从上面的键盘输入,但理想情况下我想把它保存为一个.sh,这样我就可以做了

sh code.sh < wordlist.txt
是否有任何方法可以在不创建tmp文件的情况下实现相同的结果?

您可以使用:

一个非常方便的用例是比较两台其他主机上的文件内容,而不复制任何内容:

comm -23 <(ssh host1 cat /foo) <(ssh host2 cat /foo)

使用一个破折号作为文件名参数,从stdin读取,即sort的输出

sort -u | comm -23 
-
 dictionary.txt

在Jetchisel的上述示例中,comm-23 Note bash不是sh。真管用!非常感谢你。我不知道单破折号是从管道另一端读取的选项。要学的东西太多了,谢谢!很高兴知道一个在现实世界中可以使用的实例:
sort -u | comm -23 
-
 dictionary.txt