views:

135

answers:

3

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..)
+2  A: 

From the hexdump(1) man page:

The hexdump utility is a filter which displays the specified files, or the standard input, if no files are specified, in a user specified format.

So:

echo "I am to be put into hexdump" | hexdump
Ignacio Vazquez-Abrams
+3  A: 

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.

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

So, to get the output of 'echo' into 'hexdump', use:

echo "I am to be dumped" | hexdump

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.

Jonathan Leffler
+2  A: 

here are some ways to pass text to hexdump

Stdin:

echo "text" | hexdump

Here document

hexdump <<EOF
text
EOF

to process entire file

hexdump file
ghostdog74
Ah. The other way around, Now I can do some useful automated things I've wanted.
oni-kun