views:

306

answers:

1

I'm wondering if anyone can point me at resources dealing with the low(ish) level mechanics of how output rediction works in bash. Unfortunately, I've only been able to turn up pages and pages of the basic "> sends output to a file" guides, but nothing seems to go into more detail than that.

In particular, I'm facing a strange situation whereby using the append redirector (>>) on Cygwin sometimes seems to start overwriting the target from the beginning of the file, rather than appending from the end as expected. I'm not aware of any combination of commands that can be given from bash to do this deliberately, but I wanted to get a better understanding of how the reidrection is actually handled in order to try and debug this behaviour and figure out what might be causing it.

The actual output is from a Java program that outputs straightforward progress messages via System.out.println(), in case there could be a gotcha here I'm not aware of

+3  A: 
Michael Aaron Safyan
Thanks - looking at your second point, my understanding is that ">" would specify the O_TRUNC flag to open while ">>" would specify O_APPEND, while it looks like the behaviour I observe comes from neither being specified.
Andrzej Doyle
My mistake. You're right.
Michael Aaron Safyan