Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Your behavior has nothing to do with symlinks, /dev/stdout, or anything of the sort. It's instead due to the behavior of dd. Your 1st and 3rd examples give dd a file handle that directly references the file. When using the of= option, dd performs a truncation. Your 2nd example dd is truncating the pipe between it and cat (which effectively does nothing), not the file itself. Sorry, but I do have to -1, because the behavior of an arbitrary program is unrelated to the original question, as well as incorrectly describing the behavior. P.S: dd has a notrunc option for this. Commented Jun 5, 2024 at 0:32
  • @Phemmer I just used dd as a simple tool to serve as an example for any tool that can take an output filename as an argument. The behavior is also seen with any other tool - but some (portable) tool is needed to provide examples of non-portability. To clarify: the point I'm making is that /dev/stdout and >> don't work well together on Linux, rendering /dev/stdout not portable. For testing this I actually compiled the simplest C code in order to eliminate all other options. I added some code to the answer, please see for yourself and check different OSes. The code is not portable; why? Commented Jul 3, 2024 at 23:36
  • @mvds I've also observed linux systems, not bsd/macos systems also discarding append, as per the last example in unix.stackexchange.com/q/790936/50703 Commented Feb 11 at 23:59