[CentOS] copy with bunzip2?

Tue Jan 8 10:12:14 UTC 2019
Gianluca Cecchi <gianluca.cecchi at gmail.com>

On Tue, Jan 8, 2019 at 3:59 AM Frank Cox <theatre at sasktel.net> wrote:

> 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?
>
>
Something like this below?
It requires something like ssh key access, otherwise for every file you
have to digit the password of the remote user... and also many ssh
commands...

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