Redirect to a named pipe

fifoio-redirection

I know the difference between > and >> when redirecting to a plain file. But is there a difference when redirecting to a named pipe (fifo)?

Assume the namedpipe is a named pipe. Are the following bash command equivalent?

echo something > namedpipe
echo something >> namedpipe

Best Answer

From bash's point of view, the two produce the same effect.

Either one will successfully write to the pipe if you have something reading from it, and since the pipe is a special device (rather than a file), its length will not change (as a regular file would, if you used the >> append operator). The pipe does not remember what you have written to it, after forwarding the data to the reader, so > and >> look the same.

Further reading:

Related Question