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..)
oni-kun
  • 1,775
  • 6
  • 17
  • 22

4 Answers4

9

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
  • 327,991
  • 56
  • 259
  • 343
4

On bash, you can also do

hexdump <<< "Pipe this text into hexdump"
rmmh
  • 6,997
  • 26
  • 37
3

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
  • 730,956
  • 141
  • 904
  • 1,278
2

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
  • 776,304
  • 153
  • 1,341
  • 1,358