Tutorial :In linux: writing into a FIFO


I created a new FIFO using the mkfifo command. I have a text file f.txt. I want to write the text file into my FIFO. How? Is there a unix command for that?


You can use cat:

mkfifo /tmp/foo  cat f.txt > /tmp/foo  

You'll see that it hangs, because you also need a reader process, as cat.

cat /tmp/foo  

You can also start first the reader process and then the writer one.


Just redirect into the pipe:

mkfifo /tmp/pipe  cat f.txt > /tmp/pipe &  cat /tmp/pipe  

Note, this is roughly what cat f.txt | cat does, but this a named pipe instead of an anonymous pipe.


Same as any file I think:

cat f.txt > myfifo  

Most things can be treated like files in Linux/Unix

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »