Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A while ago I saw an article about piping messages from one console window to another using fifo ?

I haven't used that before and can't find my link to the article. How can I set this up?

I'd like to have two consoles open for logging and have one display the log messages (real time) that are sent from the other one.

share|improve this question
up vote 5 down vote accepted

When a named pipe is created, via mkfifo (or however else you can do it), it creates a pipe "file" that remains in place until it is removed (or, in some cases, until your machine reboots, if you forget to remove it). You can create your own named pipe with mkfifo simply, as it takes very few arguments, like so:

host # mkfifo -m 777 /tmp/corncob

That's all it takes to create the named pipe /tmp/corncob. The -m flag, which is used to set the permissions, is not necessary. Generally, if you don't include it, the default permission set for a new named pipe is whatever the default for your system would be. As another side note, you can also pass the -m flag and set alpha permissions, rather than octal, like:

host # mkfifo -m a=rwx /tmp/corncob

to create the exact same thing. You can delete the named pipe just like you delete a file. rm, and it's gone.

One thing you should note about named pipes is that they generally (so far as I've seen) are only able to fully pass one stream of input/output through themselves at a time. That is to say, if you have one process sending input to the named pipe and two process reading from it, only one of the reading processes will receive output. It should be noted, also, that, if such a situation were to exist, once the original process that was receiving output exits, the other process would begin receiving output from the named pipe (if it was still attempting to read from it). Was that a really long sentence or am I just typing fast? ;)

An example of what I mean below:

host-term1 # while :;do echo a b c d e >/tmp/corncob;sleep 15;done

host-term2 # tail -f /tmp/corncob
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e

host-term3 # tail -f /tmp/corncob

host-term2 # ^C

host-term3 #
a b c d e
a b c d e
a b c d e
a b c d e


share|improve this answer

Use the mkfifo command to create a fifo queue, pipe the output to it (use tee instead of a redirect if you want output on both), and just cat it out on the other terminal. Just note that the fifo blocks, so you'll have to make sure the way you're using it won't stop the program.

share|improve this answer
how can i have one terminal just continuously display new matches without scrolling blank lines? – cwd Nov 11 '11 at 3:58
@cwd filter with something like grep, perhaps. – jw013 Nov 11 '11 at 4:03
Where are the blank lines coming from? cat on the fifo will only print when there's input to it. If it's in the output, you can add |sed '/^\W*$/d' to take it out. – Kevin Nov 11 '11 at 4:04
what about what loop? – Kevin Nov 11 '11 at 4:08
how can i keep the pipe open and continue to get new data? would that be looping cat or is there a better way? – cwd Nov 11 '11 at 4:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.