Tag Info

New answers tagged


The character . is only excluded from wildcard matching when it's the first character of the file name and it would be matched by a wildcard. In the pattern .*, the * matches strings beginning with ., so .* includes .. (as well as ., with * matching the empty string). This is a straightforward consequence of the pattern matching rules, annoying though it may ...


I'd think you could use ls -A instead, specifically: chown -R username:groupname $(ls -A | grep '^\.') This does what you'd expect .* to do, match all files in the current directory that begin with a ., excluding . and ... But note this won't behave identically to a bash glob if you need it to match funky file names, like files with spaces in them.


A variation of Chris Down solution that filter just hidden directories and removes the -R options. Your original requirement was to change ownership and group classification of hidden directories, not their content. find /home/username -maxdepth 1 -type d -name '.*' -exec chown user:group {} +


If the directory itself shares the same ownership as its files (hidden or not), then you can chown it recursively instead. The -R option will include hidden files when recursing inside the current directory. $ chown user:group . -R # Will include all hidden files


Using the extended globbing (shopt -s extglob), you can use .!(.|) i.e. dot not followed by dot or nothing.


Consider using find (-maxdepth is a non-POSIX extension, but it should be readily available on Linux): find . -maxdepth 1 -type d -name '.*' -exec chown -R user:group {} +


I always get burned when I try using .* for anything and long ago switched to using character classes: chown -R username.groupname .[A-Za-z]* is how I would have done this. Edit: someone pointed out that this doesn't get, for example dot files such as ._Library. The catch all character class to use would be chown -R username.groupname .[A-Za-z0-9_-]*


You need to use the --strip-components option of tar; that's because the paths you don't need are contained in the tar archive. So for instance if the tar contains this: srv/test/www.testwebsite.com/index.html and you want to obtain this mytestdirectory/index.html, you need $ cd /path/to/mytestdirectory $ tar xf testwebsite.tar --strip-components=3 If ...

Top 50 recent answers are included