recursive chmod
Paul Melson
melson@scnc.holt.k12.mi.us
Mon, 27 Nov 2000 17:54:31 -0500
On Mon, Nov 27, 2000 at 05:21:27PM -0500, Edward Glowacki wrote:
> I'm not doubting you on this, but could you explain why it's safer?
> Just curious...
xargs gives you bounds checking for creating
the command(s) you wish to execute. In Ben's
example, find would put a null character at
the end of each file & path that are output
and then require xargs to use that null as
a delimiter of sorts. It might not be such
a big deal when using chmod (although I can
conceive of some situation where it could),
but take this example:
find / -type f -name core ! -empty -print0 | xargs -0 rm -f
Now, by using '-type f' we eliminate using
symlinks to delete system files or whatever,
but you could still create a file with a
large number of spaces between 'core' and,
oh, say '/vmlinuz' in its name. Without
using '-print0' and '-0', to endicate the
end of the file's name to xargs, it would
be trivial to get a clean-up script like
this to delete system files when it runs.
You could also use find's '-printf' switch
to submit another type of "delimiter" into
its output, and this can be paired with xargs'
'-e' switch, but since xargs can use nulls
with the '-0' switch, it's an easy way to
get the job done.
PaulM
--
_____________________
melson@holt.k12.mi.us