Linux:如何正确地将文本传输到程序中?
我看过但找不到任何东西。例如,我使用的 TTS 程序可让您执行以下操作:
~#festival -tts | echo "I am to be spoken"
这确实很好,但对于我使用的程序(例如 hexdump),我不知道如何将文本通过管道传输到其中。我真的可以使用其中一些东西,我尝试过(但失败)的一些例子如下:
~#gtextpad < dmesg
//(how do I put the contents into the text pad for display? not just into a file)
~#hexdump | echo "I am to be put into hexdump"
//(How do I get hexdump to read the echo? It normally reads a file such as foo.txt..)
I've looked but can't find anything. A program for example, a TTS I use lets you do the following:
~#festival -tts | echo "I am to be spoken"
Which is really nice, but for programs I use such as hexdump, I don't know how to pipe text into it. I can REALLY use some of these things, some examples I tried (but failed) are like so:
~#gtextpad < dmesg
//(how do I put the contents into the text pad for display? not just into a file)
~#hexdump | echo "I am to be put into hexdump"
//(How do I get hexdump to read the echo? It normally reads a file such as foo.txt..)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下是将文本传递到 hexdump
Stdin 的一些方法:
echo "text" | hexdump
这里
处理整个文件的文档
here are some ways to pass text to hexdump
Stdin:
echo "text" | hexdump
Here document
to process entire file
在 bash 上,你也可以这样做
On bash, you can also do
管道(由管道符号分隔的一系列命令)中的数据流从左向右流动。因此,下面 command1 的输出将转到 command2 的输入,依此类推。
因此,要将“echo”的输出获取到“hexdump”中,请使用:
我不知道您显示的“festival”命令如何工作。 shell 做了足够多的管道工作,没有做出无根据的假设和大量的欺骗,然后仍然依赖内核中的调度决策来让事情变得“正确”,我不知道如何让它工作。
The data flow in a pipeline (series of commands separated by pipe symbols) flows from left to right. Thus, the output from command1 below goes to the input of command2, and so on.
So, to get the output of 'echo' into 'hexdump', use:
I don't see how the 'festival' command you show can work. The shell does enough plumbing that without making unwarranted assumptions and doing a lot of skulduggery and then still relying on scheduling decisions in the kernel to get things 'right', I don't see how it can be made to work.
来自
hexdump(1)
手册页:所以:
From the
hexdump(1)
man page:So: