简体   繁体   English

将bash中的stdin和stdout都重定向到不同的文件

[英]Redirect both stdin and stdout in bash to different files

I need to make some bash script that stores all its input to file/pipe and reads its output from other file pipe and run forever. 我需要制作一些bash脚本,将其所有输入存储到文件/管道,并从其他文件管道读取其输出,并永久运行。 First part is like cat - > pipein and second is like cat pipeout . 第一部分就像cat - > pipein ,第二部分就像cat pipeout But how to make both parts simultaneously? 但是如何同时制作两个零件呢?

I also tried to mess with additional file descriptors but with no success. 我也尝试弄乱其他文件描述符,但没有成功。

Found an answer! 找到了答案!

#!/bin/bash
cat pin &
cat >pout
wait

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM