Emulation of "named" process substitutions

Say I have a large gzipped file data.txt.gz, but often an ungzipped version must be provided to the program. Of course, instead of creating a standalone unpacked, data.txtyou can use the process substitution syntax :

./program <(zcat data.txt.gz)

However, depending on the situation, this can be tedious and error prone.

Is there a way to emulate a process replacement with a name ? That is, to create a pseudo file data.txtthat is “deployed” to process substitution zcat data.txt.gzwhenever it is accessed. Unlike a symbolic link, it redirects the read operation to another file, but in this case it should be a temporary named pipe.

Thank.

PS. A somewhat similar question


Edit (from comments). In the actual use case, there is a large gzipped corpus, which, in addition to using it in its original form, also sometimes needs to be processed using a series of light operations (tokens, etc.), and then served on some "heavier" code. Storing a preprocessed copy frees up disk space and re-retyping a full preprocessing pipeline can lead to errors. At the same time, when starting the conveyor on the fly, tiny computational overhead is, therefore, the idea of ​​a long-lived pseudo file that hides details under the hood.
+4
2

, , , , . , script.

script, .

+5

, , , .

, mkfifo, , fifo fifo , .

(, ), netcat, .

" netcat" , while true; do nc -l -p 1234 -c "zcat myfile.tar.gz"; done. BSD netcat :

# Make a dummy FIFO
mkfifo foo

# Use the FIFO to track new connections
while true; do cat foo | zcat myfile.tar.gz | nc -l 127.0.0.1 1234 > foo; done

, ( ) , nc localhost 1234, . , nc localhost 1234 - .

(, , ):

netcat server demo

bash script .. - - , .

, , , "" , FUSE, , , . , , , , , , -, zcat .

0

Source: https://habr.com/ru/post/1543411/


All Articles