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

mkfifo foo
echo > foo  
echo >> foo
  • 1
    mkfifo: difference between > and >> would look clearer – jsotola Jun 4 at 16:28

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.


> overwrites the destination file

>> appends to the destination file

Thanks to Jobin at AskUbuntu for the authoritative answer with 45 likes.

  • 1
    Notice that the redirections are used with a named pipe in the question, not a regular file. The question is whether > and >> has the same effect. – Kusalananda Jun 4 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy