Re: feature request: self join from stdin
On 2019-10-21 08:28, Rasmus Borup Hansen wrote: > [...] e.g. this hangs on my machine: > > mkfifo fifo && seq -s , 2 | tee fifo | join -j2 - fifo | paste -s && rm > fifo okay, then better use a regular file, and join that with itself: $ seq -s , 2 > x $ join -j2 x x | paste -s 1,2,3,4,5,6,[...] Have a nice day, Berny
Re: feature request: self join from stdin
> On 20 Oct 2019, at 19.33, Bernhard Voelker wrote: > > On 2018-11-25 17:45, furrymc...@lippydanger.jumpingcrab.com wrote: >> Please consider a self join from stdin in coreutils. >> >> $ seq 3 | join -j2 - - | paste -s >> 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 > > What about tee'ing into a 'fifo' which is read again by join? > > $ mkfifo fifo \ > && seq 3 | tee fifo | join -j2 - fifo | paste -s \ > && rm fifo > 1 11 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 > > Have a nice day, > Berny > This will hang if the lines get so long that the fifo is filled before it can be emptied, e.g. this hangs on my machine: mkfifo fifo && seq -s , 2 | tee fifo | join -j2 - fifo | paste -s && rm fifo Best, Rasmus
Re: feature request: self join from stdin
On 2018-11-25 17:45, furrymc...@lippydanger.jumpingcrab.com wrote: > Please consider a self join from stdin in coreutils. > > $ seq 3 | join -j2 - - | paste -s > 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 What about tee'ing into a 'fifo' which is read again by join? $ mkfifo fifo \ && seq 3 | tee fifo | join -j2 - fifo | paste -s \ && rm fifo 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 Have a nice day, Berny
Re: feature request: self join from stdin
On Okt 20 2019, Nomen Nescio wrote: > Do you think the following coproc solves the problem? > A join or paste prints expected results. > Curiously cat or tac will block the process. > Can you explain why join/paste finish the process whereas cat/tac block it? Because join and paste simultanously read both files, whereas cat and tac read one file after the other. Then tee blocks on stdout because nobody drains the pipe buffer. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: feature request: self join from stdin
Do you think the following coproc solves the problem? A join or paste prints expected results. Curiously cat or tac will block the process. Can you explain why join/paste finish the process whereas cat/tac block it? # ii bash 4.4-5amd64GNU Bourne Again SHell # ii coreutils 8.26-3 amd64GNU core utilities seq 10 | { coproc { cat; } && exec 3<&${COPROC[0]}- 4<&${COPROC[1]}- coproc { cat; } && exec 5<&${COPROC[0]}- 6<&${COPROC[1]}- tee >(cat >&4) > >(cat >&6) & exec 4>&- 6>&- join <(cat <&3) <(cat<&5)## GOOD # paste <(cat <&3) <(cat<&5) ## GOOD # cat <(cat <&3) <(cat <&5) ## BAD # tac <(cat <&3) <(cat<&5) ## BAD # cat <(cat <&3) & cat <(cat <&5) & ## GOOD wait }