存档(ubuntu tar)隐藏目录 [英] archiving (ubuntu tar) hidden directories
问题描述
tar将存档隐藏的文件和隐藏的子目录,而 in mydir
中的*
通配符的tar将不会存档.这是一个长期存在且已知的不一致或错误吗?
tar on a directory mydir
will archive hidden files and hidden subdirectories, but tar from within mydir
with a *
wildcard will not. Is this a longstanding and known inconsistency or bug?
编辑(其他信息):mydir
中的带通配符的tar不会看到"也不会在 immediate 目录中存档隐藏的文件和隐藏的子目录.但是,在mydir
的非隐藏子目录中,隐藏文件和隐藏子目录将被存档.
Edit (additional information): tar from within mydir
with a wildcard will not "see" nor archive hidden files and hidden subdirectories in the immediate directory. However, in the non-hidden subdirectories of mydir
hidden files and hidden subdirectories will be archived.
推荐答案
答案是*
通配符由外壳处理,只是不能扩展为以点开头的内容.另一个通配符?
也不扩展到以点开头的内容.感谢Keith指出扩展是由外壳程序完成的,因此它与tar
无关.
The answer is that the *
wildcard is handled by the shell and it just does not expand to things that start with a dot. The other wildcard ?
also does not expand to things that start with a dot. Thanks to Keith for pointing out it is the shell that does the expansion and so it has nothing to do with tar
.
如果使用shopt -s dotglob
,则扩展将包括.filename
之类的内容.感谢安迪.
If you use shopt -s dotglob
then expansion will include things like .filename
. Thanks to Andy.
使用shopt -u dotglob
将其关闭.
切换dotglob
选项不会更改ls
本身.相反,它只是更改了扩展行为,如ls *
所示.
Switching the dotglob
option does not change ls
itself. Rather it just changes expansion behaviour as exhibited in something like ls *
.
我的建议在下面的评论中.
My recommendations are in a comment below.
这篇关于存档(ubuntu tar)隐藏目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!