存档(ubuntu tar)隐藏目录 [英] archiving (ubuntu tar) hidden directories

查看:138
本文介绍了存档(ubuntu tar)隐藏目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆