ln -s . wordpress
tar xvfz latest.tar.gz wordpress
rm wordpress
Surprisingly, my tar (GNU tar v1.16) doesn't have an option to strip initial pathname elements.
However, it seems that more recent versions sport a --strip-components=number parameter, which will strip that many compononents from the start of the path.
If like me you are using an older tar, and you are certain that the archive does not contain a directory or file named wordpress/wordpress, you could always just make a symlink from wordpress to ., then extract as usual:
ln -s . wordpress
tar xvfz latest.tar.gz wordpress
rm wordpress
发布评论
评论(2)
为什么你不正常解压,然后:
但是,唉,有:
Why don't you untar normally, then just:
But alas, there's:
令人惊讶的是,我的
tar
(GNU tar v1.16) 没有删除初始路径名元素的选项。然而,最近的版本似乎带有一个
--strip-components=number
参数,该参数将从路径的开头去除许多组件。如果像我一样,您使用的是较旧的
tar
,并且您确定存档不包含名为wordpress/wordpress
的目录或文件,您始终可以创建一个符号链接从wordpress
到.
,然后照常提取:Surprisingly, my
tar
(GNU tar v1.16) doesn't have an option to strip initial pathname elements.However, it seems that more recent versions sport a
--strip-components=number
parameter, which will strip that many compononents from the start of the path.If like me you are using an older
tar
, and you are certain that the archive does not contain a directory or file namedwordpress/wordpress
, you could always just make a symlink fromwordpress
to.
, then extract as usual: