我知道如何从 tarball 中提取单个文件,尽管现在我有 500 GB 的tar
文件,没有任何压缩,只是一个普通tar
文件,我想专门提取 3 个目录,其结构如下:
dir1/subDir1/
dir2/subDir2/
dir3/subDir3/subSubDir3/
Run Code Online (Sandbox Code Playgroud)
每个里面都有很多子目录和很多文件。我希望简单地提取其中的所有内容。
我很好奇如何做到这一点,而不必提取整个 tarball。
tar
提取像文件一样的目录,请参阅man page
获取更多信息。
# -v; verbose parameter is rather obstructive
# in case of thousands and thousands of files
tar -xf archive.tar directory/
Run Code Online (Sandbox Code Playgroud)
您可以使用该--strip-components=n
选项。
tar -xvf archive.tar --strip-components=4
Run Code Online (Sandbox Code Playgroud)
--strip-components=NUMBER
Run Code Online (Sandbox Code Playgroud)strip NUMBER leading components from file names on extraction