I want to tar the output of a program that writes to stdout and a fifo at fd=3. Here was 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>&-
It created ha.tgz and its contents were /dev/fd/1 and /dev/fd/3. However when I extract the files, it basically creates symlinks to /dev/fd/1 and /dev/fd/3 (which is broken). I was hoping the files would just be regular files whose content would be what I echo'd in the script. Is there a way to do this?
Is there a way to do this?
No. The entries under /dev are not real files, they are only file-like interfaces to device drivers. If you want regular files, use regular files.
Just pipe the fifo contents into gzip and to a file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With