[ale] Baffled on chmod usage

Michael H. Warfield mhw at wittsend.com
Thu Aug 10 16:23:29 EDT 2000


On Thu, Aug 10, 2000 at 04:25:56PM -0400, Jeff Hubbs wrote:
> I want to chmod all the .exe files within and below the directory "public,"
> so I go:

> 	# cd /<path>/public
> 	# chmod -Rv 555 *.exe

> but I get

> 	chmod: *.exe: No such file or directory

> FWIW, there are no .exe files in public, but there are many of them
> scattered in directories underneath public.  What I especially don't
> understand is that if I go 

> 	# chmod -Rv 555 *

> then everything and its brother in public and below gets chmodded.  I can
> use some other extension besides .exe that I know is present but I still get
> No such file or directory.

> Am I misusing wildcards in bash or something?

	Bingo!

	The * gets expanded by the shell to everything in that directory.
*.exe doesn't match anything in that directory so it doesn't get expanded
and chmod doesn't do regex matching.  You would see the same thing happen
with chmod -Rv 555 '*' (the two single quotes would prohibit the shell
from doing expansions).

	To do what you want to do, I would use find like this:

	find . -name \*.exe -exec chmod 555 \{\} \;

	Note ALL of the backslashes are important.

	That command says that starting in this directory, search for any
name ending in '.exe'.  For every name found, execute the command
chmod 555 ${fname}  (the file name substitution is the \{\}).  The
\; terminates the command for find.

> - Jeff
> --
> To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.

-- 
 Michael H. Warfield    |  (770) 985-6132   |  mhw at WittsEnd.com
  (The Mad Wizard)      |  (678) 463-0932   |  http://www.wittsend.com/mhw/
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!

--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list