4 ms·
How is input to a pipe reversed?
by jooize 6y ago
How is input to a pipe reversed?
- umanwizard 6y agoBy saving all the input in memory (EDIT: or to a file, as another comment points out) until EOF, then writing the lines out in reverse order. It's not really possible to do in a stateless/streaming way.
- wolfgang42 6y agoIt’s written to a seekable tempfile first: https://github.com/coreutils/coreutils/blob/6a3d2883fed853ee01079477020091068074e12d/src/tac.c#L542-L556 https://github.com/coreutils/coreutils/blob/6a3d2883fed853ee...