tar 压缩命令的最有用的一个选项了

来源:互联网 发布:js压缩视频文件 编辑:程序博客网 时间:2024/05/20 12:21
tar cf - rootfs.rls | ssh root@192.168.1.2  "tar -C /home/et3320 -xvf -"


把整个的rootfs.rls目录给上传到1.2的/home/et3320目录。 且tar不改变任何连接和文件等的信息。

注意的一点是,打包和登陆的用户都必须是root用户,否则,某些文件或者设备会丢失。

Because tar saves the ownership and permissions of files in the archive and retains the full
directory structure, as well as symbolic and hard links, using tar is an excellent way to copy
or move an entire directory tree from one place to another on the same system (or even
between different systems, as we'll see).

And tar allows you to write an ahchive to standard output. If you specify a - as the tar file to read or write, the data will be read from or write to the standard input or standard output. 

We start in the directory rootfs and create a tar file of the current directory, which is written to standard output. This archive is read by a ssh  and then runs tar xvf, reading from standard input. No tar file is ever written to disk; the data is sent entirely via pipe from one tar process to another. The second tar process has the v option that prints each file as it's extracted; in this way, we can verify that the command is working as expected.