我知道我可以跑
$ tar xf somefile.tar.gz -C somedir
Run Code Online (Sandbox Code Playgroud)
将 tar.gz 文件提取到 somedir,但它需要 somedir 首先存在。
有没有办法提取到目录并在目录不存在时动态创建该目录?
小智 5
使用 GNUtar命令,您可以执行以下操作:
tar -xf somefile.tar.gz --one-top-level=somedir
Run Code Online (Sandbox Code Playgroud)
从man 1 tar:
--one-top-level[=DIR]
Extract all files into DIR, or, if used without argument, into a subdirectory named
by the base name of the archive (minus standard compression suffixes recognizable
by --auto-compress).
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8034 次 |
| 最近记录: |