bashgunzip

How to send gunzip stream to another server without decompressing on local side?


I've got this bash command:

gunzip db.gz | ssh user@host mysql -uroot -ppassword db

It works, but has a side effect of decompressing the db.gz file which then has to be recompressed. I want to leave the compressed file in tact. I did a man 'gunzip' but didn't see an option for anything like this.


Solution

  • One option could be to send the file over the network in its compressed form and to decompress the stream on the receiving side.

    ssh user@host "gunzip | mysql -uroot -ppassword db" < db.gz