I wrote a very similar post nearly three years ago (in German) and still need this daily. As I’m currently writing a lot of Dockerfiles, I realised my post wasn’t completely accurate. Although I redacted it, it’s a good opportunity to port the original post to the english language.
Select all files in a directory, including hidden ones or files beginning with crude symbols. But exclude . and .. as those will most likely lead to an exit code > 0.
Lets assume we want to chown all files in the directory /var/www/html:
Notice how we got a lot of strange filenames here, including files beginning with dashes or double dots.
A combination of three Shell Wildcards solves our problem:
Lets inspect those three a little closer…
/var/www/html/* - Matches every “normal” file and directory, so no hidden ones, but including the files beginning with dashes
/var/www/html/.[!.]* - Matches every file and directory beginning with a dot but not having a second dot afterwards. So most of the “normal hidden” files
/var/www/html/.??* - Matches every file and directory beginning with a dot and having at least two additional characters
Not the most intuitive way, but it checks out. If you want to have different solutions, check Superuser.