How to warp fifo

I want to deactivate the output of a program that writes to stdout and fifo at fd = 3. Here is my first attempt:


#!/bin/bash

#Create fd=3
exec 3> >(cat)

#Start the tar
tar -cvzf ha.tgz /dev/fd/1 /dev/fd/3

#Write data
echo stdout
echo 'fd=3'>&3

#close
exec 3>&-

He created ha.tgz, and its contents were / dev / fd / 1 and / dev / fd / 3. However, when I extract the files, it basically creates symbolic links to / dev / fd / 1 and / dev / fd / 3 (which doesn't work). I was hoping that the files would be just regular files, whose content would be what I did in the script. Is there any way to do this?

+3
source share
3 answers

Is there any way to do this?

No. Entries under / dev are not real files; they are just file interfaces for device drivers. If you need regular files, use regular files.

+3

zip :

zip -FI MyZipFile /dev/fd/1 /dev/fd/3

+2

Just merge the contents of fifo with gzipand with the file.

+1
source

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


All Articles