2010-02-07 24 views
1

我看了,但找不到任何東西。程序例如,我使用TTS可以讓你做到以下幾點:Linux:我如何正確地將文本輸入程序?

~#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..) 

回答

3

這裏是通過文字進制打印

標準輸入的一些方法:

echo "text" | hexdump

這裏記錄

hexdump <<EOF 
text 
EOF 

來處理整個文件

hexdump file 
+0

啊。反過來,現在我可以做一些我想要的有用的自動化的東西。 – 2010-02-07 05:36:48

2

hexdump(1)手冊頁:

的hexdump工具是顯示指定的一個過濾器文件或標準輸入,如果沒有指定文件,則以用戶指定的格式。

所以:

echo "I am to be put into hexdump" | hexdump 
3

在管線中的數據流(一系列由管道符號分開的命令的)流從左到右。因此,下面的command1的輸出轉到command2的輸入,依此類推。

command1 | 
command2 | 
command3 arg1 arg2 arg3 | 
sort | 
more 

因此,要獲得「迴響」輸出到「hexdump都」,使用:

echo "I am to be dumped" | hexdump 

我沒有看到你展示「節日」命令是如何工作的。 shell做了足夠的準備工作,沒有做出不合理的假設,做了大量的詭計,然後仍然依靠內核中的調度決策來讓事情「正確」,但我不明白它是如何工作的。

2

在bash上,你也可以做

hexdump <<< "Pipe this text into hexdump" 
相關問題