Question

I am trying to gunzip a file and then keep the results in a named pipe created using mkfifo which will ultimately be used in a join command. I have seen many examples on using mkfifo to gzip things but almost nothing on gunzipping in this type of scenario. The overview of my problem is:

Get the contents of two *.gz files without actually unzipping them to disk. To do this capture the stream of gunzip -c *.gz (this is where I want to use a named pipe to act as a file holding the contents of the stream). Take the the two named pipes and perform a join on them. The simplified idea in unix code is sort of like...

mkfifo pipe1
mkfifio pipe2

gunzip -c fileA.gz > pipe1 &
gunzip -c fileB.gz > pipe2 &

join pipe1 pipe2

rm pipe1 pipe2

Any advise would be appreciated

Was it helpful?

Solution

You don't really need named pipes for this. Bash has a special syntax that can do this in one command:

join <(gunzip -c fileA.gz) <(gunzip -c fileB.gz)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top