创建 tar.gz 个存档并添加没有父文件夹的所有文件和文件夹
Create tar.gz archive and add all files and folders without parent folder
例如,我有文件夹 "admin",其中包含文件夹“1”和两个 php 文件 "index.php" 和 "page.php"。我尝试使用 tar -zcvf admin.tar.gz admin
并获得 admin.tar.gz 存档。如果我打开这个存档,我可以看到存档包含 "admin" 文件夹并且在这个目录中是文件夹“1”和两个 php 文件。
我想创建包含所有文件和文件夹但没有父文件夹的 tar.gz 存档。创建存档,它仅包含文件夹“1”和两个 php 文件。我该怎么做?
您可以使用 -C
选项:
tar -C admin -zcvf admin.tar.gz .
见man tar
-C, --directory=DIR
Change to DIR before performing any operations.
This option is order-sensitive, i.e. it affects all options that follow.
例如,我有文件夹 "admin",其中包含文件夹“1”和两个 php 文件 "index.php" 和 "page.php"。我尝试使用 tar -zcvf admin.tar.gz admin
并获得 admin.tar.gz 存档。如果我打开这个存档,我可以看到存档包含 "admin" 文件夹并且在这个目录中是文件夹“1”和两个 php 文件。
我想创建包含所有文件和文件夹但没有父文件夹的 tar.gz 存档。创建存档,它仅包含文件夹“1”和两个 php 文件。我该怎么做?
您可以使用 -C
选项:
tar -C admin -zcvf admin.tar.gz .
见man tar
-C, --directory=DIR
Change to DIR before performing any operations.
This option is order-sensitive, i.e. it affects all options that follow.