[X-Unix] need help with a command

Scott J. Kramer x-unix at sjk.us
Tue Mar 1 14:43:45 PST 2005


--On Tuesday, March 1, 2005 16:28 -0500 PoolMouse <poolmouse_nyc at mac.com> 
wrote:

> how do i create a script that applies permissions (recursively) to a
> directory...on all contents/subdirectories/etc, EXCEPT folders beginning
> with:
>
> 	~ARCHIVE

Assuming that's really a directory starting with a tilde '~' character
and not user ARCHIVE's home directory, something like:

  find PATH -not \( -type d -a -name '~Archive' \) -exec chmod MODE {} \;

But that'll match special files, e.g. symlinks and sockets.  Also,
sometimes it's best handling directories and non-directory files
separately when changing permissions, e.g. setting the 'x' (execute)
bit makes sense for directories but not for non-executable traditional
Unix files.  So, you could construct two commands like:

  find PATH -type d -not -name '~Archive' -exec chmod DIR-MODE {} \;
  find PATH -type f -exec chmod NONDIR-MODE {} \;

... for changing dirs and regular files separately.

-sjk



More information about the X-Unix mailing list