archiving (ubuntu tar) hidden directories

后端 未结 6 732
迷失自我
迷失自我 2021-02-02 11:48

tar on a directory mydir will archive hidden files and hidden subdirectories, but tar from within mydir with a * wildcard will no

6条回答
  •  孤城傲影
    2021-02-02 12:13

    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.

    If you use shopt -s dotglob then expansion will include things like .filename. Thanks to Andy.

    Use shopt -u dotglob to turn it off.

    Switching the dotglob option does not change ls itself. Rather it just changes expansion behaviour as exhibited in something like ls *.

    Edit: My recommendations are in a comment below.

提交回复
热议问题