用tar归档隐藏目录 [英] archiving hidden directories with tar

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

问题描述

tar 将存档隐藏的文件和隐藏的子目录,但是tar来自 in mydir * 通配符不会.这是已知的不一致或错误吗?

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 known inconsistency or bug?

附加信息.带有 * 通配符的 in mydir 中的 tar 不会看到";也不将隐藏文件和隐藏子目录归档在 immediate 目录中.但是,在 mydir 的非隐藏子目录中,隐藏文件和隐藏子目录将被存档.换句话说,在目录树的更深处,隐藏的对象将被存档.

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. In other words, deeper in the directory tree the hidden objects will be archived.

推荐答案

答案是 * 通配符由shell处理,并且不会扩展为以点开头的内容.另一个通配符?也不扩展到以点开头的内容.感谢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.

这篇关于用tar归档隐藏目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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