About tar analog cp commands

95 3

Examples are as follows, I can't understand. cp -r/etc/tmp Why don't you use tar. tar -cvf -/etc | tar -xvf - In contrast to the cp, there's nothing special.

Example eight: after packaging the/etc/directly under/tmp, don't produce a file.
[ root @ ] # ~ cd/tmp
[ root @ ] # -cvf -/etc | tar -xvf - tar
It's a bit like # -r/etc/tmp. ~ is still in its use.
It's important to note where # is in the output file - and the input file becomes - and there's a | existence ~.
#, which represents standard output, standard input and pipeline commands.

4 Answers

144 5

There's a common experience: There's a lot of a lot of. It's time to get rid of it. For example: when backing up and restoring a web site file, it's usually not loaded directly, but it's a package.

It's the same game. If the direct cp command, its quality is read a file and then writes a file. By the tar pipe relay, you can make full use of the size of the pipeline, essentially reading the size of a buffer, then write a buffer size. This makes it possible for small files to automatically implement a single batch of readings.

Tar can do this, and flip out to the tar package in a convenient order in order to flow in and out of order. The tar format is basically: [TAR文件头][文件实际内容][TAR文件头][文件实际内容].. .... [TAR文件头][文件实际内容][TAR文件尾] So the latter level of tar can flow into a bit of data processing, without waiting for the entire tar package to come out.

97 2

Performance issues.
A cp command reads the file one by one, then writes to the new location.
A tar command will to read the contents of the file as much as possible, and then write the new location in a batch.

...