command > /dev/null
But appending to /dev/null works too :
command >> /dev/null
Except for the extra character, is there any reason not to do this ? Is either of these "nicer" to the underlying implementation of /dev/null ?
The open(2) manpage says lseek is called before each write to a file in append mode:
The file is opened in append mode. Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). The modification of the file offset and the write operation are performed as a single atomic step.
which makes me think there might be a tiny performance penalty for using
>>. But on the other hand truncating /dev/null seems like an undefined operation according to that document:
If the file already exists and is a regular file and the access mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0. If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise, the effect of O_TRUNC is unspecified.
So, is truncating /dev/null actually unspecified ? And do the lseek calls have any impact on write performance ?