At first I thought this answer was the solution, but now I think I need a temporary file as buffer.This works unreliably:#!/bin/shecho 'OK' |{    {        tee /dev/fd/3 | head --bytes=1 >&4    } 3>&1 | tail --bytes=+2 >&4} 4>&1When I run this in a terminal, sometimes I get:OKand sometimes I get:K  OSeems totally random. So as a workaround I'm writing the output of tail to a file and reading it back to stdout after the pipe has finished.#!/bin/shecho 'OK' |{    {        tee /dev/fd/3 | head --bytes=1 >&4    } 3>&1 | tail --bytes=+2 >file} 4>&1cat fileCan this be done in dash without temporary files? Shell variables as buffer aren't an option either, as the output might contain NUL bytes.
dash: Pipe STDIN to multiple commands and their output to STDOUT in defined order
pipe;io redirection;file descriptors;tee;dash