Re: confusing behaviour of the * wildcard when handling "dot" files and dirs.



At Wed, 30 Jul 2008 01:05:23 GMT Unruh <unruh-spam@xxxxxxxxxxxxxx> wrote:


Rahul <nospam@xxxxxxxxxxxxxx> writes:

I tried going to /home/foouser/ and then doing a 'chown -R foouser *'

It seems to change the ownership recursively for all dirs and files under
/home/foouser/ except those starting with a . (dot)

Is this behaviour of the * wildcard by design or am I just missing
something here? I'm confused!

By design. * does NOT capture files which start with a . on purpose. Those
are supposed to be hidden, and thus echo * is not supposed to display them.
Since * is expanded by the shell not the program, it has to be consistant.
To get the . files, do
ls .??*

Or better:

ls -A
or
ls -a

(-a includes ALL . files, include . and .., -A includes all . files
*except* . and .. -- see 'man ls' for more information.)


If you do just .* or .?* you will capture in the first instance both . and
.. as well and if you do .?* you will capture .. This is pretty dangerous
if you are doing
rpm -r .*
for example.

Remember to always do
.??* as the wildcard for . files.


--
Rahul


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

.