- 论坛徽章:
- 0
|
好像有点问题哦,我给你一点参考。
-----------------------------------------------------------------------------------
root:/tmp/tar#tar cvf 1.tar test* (tar创建文件的时候没有制定要创建文件的绝对路径,那么创建的tar文件只会解压到当前目录)
a test/22 9 blocks
a test.com 2 blocks
a test.conf 9 blocks
root:/tmp/tar#ll
total 80
-rw-rw-rw- 1 root sys 20480 Jun 23 16:26 1.tar
drwxrwxrwx 2 root sys 96 Jun 23 16:24 test
-rw-rw-rw- 1 root sys 678 May 19 17:19 test.com
-rwxr--r-- 1 root sys 4305 May 23 17:04 test.conf
root:/tmp/tar#rm -rf test*
root:/tmp/tar#ll
total 48
-rw-rw-rw- 1 root sys 20480 Jun 23 16:26 1.tar
root:/tmp/tar#tar xvf 1.tar
x test/22, 4505 bytes, 9 tape blocks
x test.com, 678 bytes, 2 tape blocks
x test.conf, 4305 bytes, 9 tape blocks
root:/tmp/tar#ll
total 80
-rw-rw-rw- 1 root sys 20480 Jun 23 16:26 1.tar
drwxrwxrwx 2 root sys 96 Jun 23 16:26 test
-rw-rw-rw- 1 root sys 678 May 19 17:19 test.com
-rwxr--r-- 1 root sys 4305 May 23 17:04 test.conf
-------------------------------------------------------------------
root:/tmp/tar#ll
total 32
drwxrwxrwx 2 root sys 96 Jun 13 14:54 test
-rw-rw-rw- 1 root sys 678 May 19 17:19 test.com
-rwxr--r-- 1 root sys 4305 May 23 17:04 test.conf
root:/tmp/tar#tar cvf 1.tar /tmp/tar/test*(指定具体目录,解压的tar包便会创建在该目录)
a /tmp/tar/test/22 9 blocks
a /tmp/tar/test.com 2 blocks
a /tmp/tar/test.conf 9 blocks
root:/tmp/tar#rm test*
rm: test directory
root:/tmp/tar#rm -rf test*
root:/tmp/tar#ll
total 48
-rw-rw-rw- 1 root sys 20480 Jun 23 16:30 1.tar
root:/tmp/tar#tar xvf 1.tar
x /tmp/tar/test/22, 4505 bytes, 9 tape blocks
x /tmp/tar/test.com, 678 bytes, 2 tape blocks
x /tmp/tar/test.conf, 4305 bytes, 9 tape blocks
root:/tmp/tar#ll
total 80
-rw-rw-rw- 1 root sys 20480 Jun 23 16:30 1.tar
drwxrwxrwx 2 root sys 96 Jun 23 16:31 test
-rw-rw-rw- 1 root sys 678 May 19 17:19 test.com
-rwxr--r-- 1 root sys 4305 May 23 17:04 test.conf
--------------------------------------------------------------------------
tar cf - .|(cd /tmp/tar2;tar xvf -)将当前目录拷贝到另外一个目录. |
|