Re: confusing behaviour of the * wildcard when handling "dot" files and dirs.
- From: Robert Heller <heller@xxxxxxxxxxxx>
- Date: Tue, 29 Jul 2008 20:05:24 -0500
At Tue, 29 Jul 2008 23:44:32 +0000 (UTC) Rahul <nospam@xxxxxxxxxxxxxx> wrote:
Allen Kistler <ackistler@xxxxxxxxx> wrote in
news:e6Njk.15713$xZ.11898@xxxxxxxxxxxxxxxxxxxx:
You're not missing anything.
That's the design.
It keeps you from changing the current directory, the parent
directory, and (in the case of -R) all the children of the parent
directory.
Ah! That explains the mess I created then! :-(
I tried a 'chown -R foouser .*' and screwed up tons of user permissions
since it acted on the .. dir too which wasn't the way I intended. My stupid
mistake.
But then again: how does one tackle dirs of the sort .ssh/ .vim/ etc.? If
these also reside under /home/foouser and I want to chown them don't I need
to have a way to wildcard them? (by going up one level and doing a chown -R
foouser /home/foouser/ seems an option...)
It is a common mistake to (miss-)use wildcards with file operations
that do recursive operations on their own (this especially includes tar
-- one almost NEVER uses a wildcarded file spec with tar, but generally
applies as well to chown, et. al. when using the -R option).
The important thing to remember is this: the wildcards are expanded by
the *shell* *NOT* by the program you are using. If the program is going
to be traversing directories on its own, 'helping' it with wildcards often
confuses things. Once this is clear, all sorts of errors are avoided.
If you are chown'ing all of the files in a given directory, you don't
really need to use a wildcard at all:
cd /home/foouser
chown -R foouser .
As another poster suggested, it is possible to use a wildcard that will
NOT match . or .., but will match all other .<mumble> files:
Here is an example that matches .<mumble> files and directories with at
least two characters after the dot:
chown -R .??*
--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller@xxxxxxxxxxxx -- Contract Programming: C/C++, Tcl/Tk
.
- Follow-Ups:
- References:
- Prev by Date: Re: confusing behaviour of the * wildcard when handling "dot" files and dirs.
- Next by Date: Re: confusing behaviour of the * wildcard when handling "dot" files and dirs.
- Previous by thread: Re: confusing behaviour of the * wildcard when handling "dot" files and dirs.
- Next by thread: Re: confusing behaviour of the * wildcard when handling "dot" files and dirs.
- Index(es):
Relevant Pages
|