Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the idiomatic way to do the following

  • tar to stdout
  • read this tar output from stdout and extract to some other folder.

My solution is tar --to-stdout .. | tar -C somefolder -xvf -

But may be there is more idiomatic way to do it.

share|improve this question
up vote 9 down vote accepted

The same -f - option works for tarring as well.

tar -cf - something | tar -C somefolder -xvf -

GNU tar uses stdio by default:

tar -c something | tar -C somefolder -xv

rsync is also popular.

rsync -av something/ somefolder/
share|improve this answer

Just adding another use-case here. I had a large directory structure on a system nearly out of disk space and wanted to end up with a tar.gz file of the directory structure on another machine with lots of space.

tar -czf - big-dir | ssh user@host 'cat > /path/to/big-dir.tar.gz'

This saves on network overhead and means you don't have to tar on the other side in case you'd wanted to use rsync for the transfer instead.

share|improve this answer
Netcat is perfect for this. (Cat from one host to another host). – Hennes Jun 25 '15 at 16:40
@Hennes: With its lack of authentication, integrity checking, data encryption, as well as having to manually start it on both sides for each individual transfer (i.e. 2× the work), it sounds a bit less than perfect – grawity Jul 23 '15 at 7:00
Most of the time I gzip it before dumping it over the network. Any integretiy failures are likely to show up as decompression errors (though I never got any when I used it). As to starting two programs: Aye, true. – Hennes Jul 23 '15 at 7:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.