Search code examples
linuxsystem-callsgnu-coreutils

Why doesn't tee use tee


There is a gnu coreutils program 'tee' and a linux(/libc?) syscall 'tee'. The program tee does not call tee. Instead it 'read's and then 'fwrite's (multiple times of course).

Why doesn't tee use tee? I assume this is either for performance or portability, but I could not find an answer.

Followup question, why does it 'read' and 'fwrite', instead of either 'read'/'write' or 'fread'/'fwrite'?


Solution

  • tee(2) only works between pipes. tee(1) needs to work between regular files, as in tee file2 < file1 > file3.

    For more details, see man 2 tee.