我正在尝试运行一个应用程序(比如说top
),以便它从文件中读取stdin并将stdout写入另一个文件。
目前我有以下代码:
mkfifo stdin.pipe
(tail -f stdin.pipe) | top
如预期工作正常,因此我可以通过echo
一些内容到该文件中,然后top将接收到它。
但是,我无法重定向top的输出。
我该如何实现?
编辑:
好的,让我们放弃top。 我正在使用这个进行测试:
cat test.sh
echo Say something
read something
echo you said $something
top
从stdin
读取吗?我的不是。你可以使用-b
(批处理)选项重定向top
的输出:top -n 1 -b > gash
- cdarke