2009-03-9, 05:03(-07), simonm: > Hi all, > > Here's a quick one... > > The following works as expected: > > # exec 9<>test.file ; jot 50 >&9 ; tail -5 <&9 9>&- > 46 > 47 > 48 > 49 > 50
That must be a bug in your tail implementation. That output should only happen if test.file already contains those 5 lines past the output of jot. tail -5 <&9, should start reading from the current position of the fd 9 in the file, that is just after where it has been left by "jot". So unless jot does an lseek back, tail shouldn't output anything. A possible explanation is that your tail implementation does a seek to the end of the file and then seeks back as an optimisation when it realises that its stdin is connected to regular file, without realising (checking) that it went back past the starting point. With my tail: ~$ exec 9<>test.file ; seq 50 >&9 ; tail -5 <&9 9>&- ~$ exec 9<>test.file ; seq 50 >&9 ; perl -e 'seek STDIN,0,0' <&9; tail -5 <&9 9>&- 46 47 48 49 50 ~$ seq 100 > test.file; exec 9<>test.file ; seq 50 >&9 ; tail -5 <&9 9>&- 96 97 98 99 100 [...] > I'd like to "split" output from a pipe to perform multiple end-steps > after a long-chain of pipes. FD redirection seems to be the best way. > > Many thanks in advance for any ideas as to why "head" doesn't work and > "tail" does. [...] Not sure what you're trying to achieve. Have you got some example? Note that comp.unix.shell would be a better place to ask kind of question. -- Stéphane