-C, --directory DIR
change to directory DIR
[root@hongdi lhd]# tar -cvf c.tar -C /home/lhd a.txt
a.txt
[root@hongdi lhd]# tar -tvf c.tar
-rw-rw-r-- lhd/lhd 10240 2009-02-03 13:12 a.txt
本文介绍了Linux中tar命令的使用方法,特别是如何通过指定目录来压缩文件。示例展示了如何将/home/lhd/a.txt压缩到名为c.tar的归档文件中。
-C, --directory DIR
change to directory DIR
[root@hongdi lhd]# tar -cvf c.tar -C /home/lhd a.txt
a.txt
[root@hongdi lhd]# tar -tvf c.tar
-rw-rw-r-- lhd/lhd 10240 2009-02-03 13:12 a.txt
626
4938

被折叠的 条评论
为什么被折叠?