The `>>` operator adds to a file instead of replacing it. Today's change is one flag different from yesterday, but it teaches the distinction between truncating and appending that every log file depends on.
Implement `>> file` so output is appended to the file rather than overwriting it.
>> is >’s gentler sibling: it points standard output at a file just the same,
but appends to whatever is already there instead of wiping the file first. The
entire difference is one flag when you open the file - truncate for >,
append for >> - which is why it fits in a single lesson on top of yesterday’s
work.
The distinction matters more than it looks. command > log starts the log fresh
every run; command >> log accumulates history across runs. Getting the open
flags right is the whole job: open with create-and-append for >>, and the
operating system positions every write at the current end of the file, even if
another process is appending too. Record >> as a second redirection kind
alongside > in the list you built yesterday.
// same as '>' but O_APPEND instead of O_TRUNCint flags = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC);int fd = open(target, flags, 0644);dup2(fd, 1);