I’m so baffled I had to ask – why this behaviour?

cd /var/www/html
tar czf ~/package.tgz admin/* api/* mobile/*

I do this, and the resulting package doesn’t include a couple of hidden files – api/.htaccess and admin/.htaccess. However…

cd /var/www/html
tar czf ~/package.tgz *

This time the hidden .htaccess files are there.

Does anybody have enlightenment to offer as to why?

  • nous
    link
    fedilink
    English
    arrow-up
    1
    ·
    6 months ago

    Not quite. . is just a character like everything else. It is no more a pattern then a is. Wildcards in bash and POSIX shells do not treat . specially as they do not use regexing rules. ? is the match any single char wildcard.

    But none of that really matters here as the . is in the filename which is never treated as a pattern. Otherwise * would not match foo.bar which makes no sense. This behaviour is only when the . is the first char and has nothing to do with the pattern or . being part of a pattern or not.