views:

1329

answers:

3

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?

+2  A: 

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.

Chas. Owens
+1  A: 

Same as any file I think:

cat f.txt > myfifo

Most things can be treated like files in Linux/Unix

Aiden Bell
+5  A: 

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.

Jaime Soriano