Tag Info

New answers tagged

-1

A git-based solution is especially useful if you need to deploy your files to different machines, and even more so if you have parts that are common to all machines, and parts that are specific to some machines. You can make multiple repositories and use a tool like multigit or vcsh to clone them over the same directory (your home dir in this case).


10

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 ...


1

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.


1

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 {} +


6

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


10

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


6

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 {} +


17

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_-]*



Top 50 recent answers are included