Difference between > and >> when used with a named pipe

fifoio-redirection

Is there any difference between the two redirections in the following code?

mkfifo foo
echo > foo  
echo >> foo

Best Answer

There should be no difference. The >> will open the fifo with the O_APPEND flag, and that shouldn't make any difference on a fifo or other non-seekable file.

However, there are buggy interfaces like sendfile(2) in Linux, which do not work with files opened in O_APPEND mode, and will object even to non-seekable files having that mode set, so you better always use the > form.

Related Question