[X-Unix] script: setting directory ownership to the name of that directory ?

Cloyce D. Spradling cloyce+xunix at headgear.org
Sun Aug 14 06:41:26 PDT 2005


On Sun, Aug 14, 2005 at 08:17:08AM -0400, macosxforme wrote:
: I have a base folder/directory, and within it, will be a long list (800 or
: so) of directories.

If it's only 800 or so, try this (Bourne-ish shell assumed; if you're using
CSH, I don't remember enough to help you:)...

  for i in `ls`; do
    chown admin:$i $i
  done

At some point you might run into problems with command line length.  On OS X,
the limit is pretty high (I think around 32KB, but I'm not sure), so that
should be good for up to at least several thousand users.  Past that, it's
easy to just break them up into groups, as in

  for i in `ls -d [a-m]*`; do
    chown admin:$i $i
  done
  for i in `ls -d [n-z0-9]*`; do
    chown admin:$i $i
  done

HTH
--
Cloyce


More information about the X-Unix mailing list