DevHeads.net

copy with bunzip2?

I have several pdf files as .pdf.bz2, as seen here:

a/1.pdf.bz2
a/2.pdf.bz2
a/b/3.pdf.bz2
a/b/c/4.pdf.bz2

I want to copy everything in and under directory a to another computer, but I want the files to be decompressed on the destination machine:

a/1.pdf
a/2.pdf
a/b/3.pdf
a/b/c/4.pdf

I could just use rsync and run a bunch of bunzip2 commands on the destination after the copying is completed, but perhaps there's a better way that would decompress the files in transit instead?

Comments

Re: copy with bunzip2?

By Gianluca Cecchi at 01/08/2019 - 06:12

for file in $(ls -1 a/*bz2)
do
echo $file
pdf_file=$(basename $file .bz2)
echo $pdf_file
bunzip2 -c $file | ssh remote_host "mkdir -p ${HOME}/b ; cat >
${HOME}/b/${pdf_file}"
done