3

The command below extracts the specified file in a remote machine:

tar -xzOf file.tar.gz file_you_want_to_extract | ssh user@host 'cat > /path/to/destination_file'

My requirement is that I want to extract all the files in to the remote machine. How can i achieve this ?

tar -xzOf file.tar.gz | ssh user@host 'cat > /path_dir'

All the files in file.tar.gz should be extracted in the remote host in /path_dir .

1 Answer 1

8
cat myfile.tgz | ssh user@host "tar xzf - -C /some/dir"
1
  • Even better than the verbose file listing cat myfile.tgz | ssh user@host "tar xvzf - -C /some/dir" is the pv progress bar! pv myfile.tgz | ssh user@host "tar xzf - -C /some/dir"
    – dtmland
    Commented Jun 8, 2020 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .