[lug] Recursive chmod

Tkil tkil at scrye.com
Fri May 4 09:38:52 MDT 2001


>>>>> "Chip" == Chip Atkinson <catkinson at circadence.com> writes:

Chip> Find is your friend:
Chip> find . -name "*.html" | xargs chmod a-x
Chip> or
Chip> find . -name "*.html" -exec chmod a-x {} \;

note that the first version should be faster/more efficient than the
second, if you have lots of files.

also, you can find both of them with "find" command.  Adding two
enhancements (files only, as someone else has already mentioned, and
making it case-insensitive using a gnu extension), and using the
slightly more secure "-print0" method to avoid getting confused by
filenames which contain newlines:

  find . -type -f \( -iname '*.jpg' -o -iname '*.jpeg' -o \
                     -iname '*.htm' -o -iname '*.html' \) -print0 | \
    xargs -0 chmod a-x

t.



More information about the LUG mailing list