On 09/10/2010 08:47 AM, Eric Blake wrote:
On 09/10/2010 03:30 AM, Dibyajyoti Ghosh wrote:
Hi,
I needed to change the timestamp of a directory structure of very high
depth. and in each level there are lots of files and folders.
So I expected a recursive operation of "touch" (like -R in chmod or in
chown
etc.).
Thanks for the report. However, we are reluctant to bloat any more tools
with recursive traversal than absolutely necessary - the whole Unix
philosophy is that each tool should do one thing well, rather than
making every tool copy common actions from other tools.
For the record, on of the reasons that ls and du must support recursion
is that they must list totals, where the use of find|xargs might cause
multiple tool invocations which end up breaking reporting of totals.
Tools like chmod, chown, rm, and mv must support recursion because there
are some particular end-result ownership and permissions which require
intermediate settings to still allow safe recursion, but there is no way
to express temporary ownerships needed only for the duration of the
recursion when using find|xargs. Besides, all of the above-named tools
have recursion required by POSIX.
But for touch, which neither outputs a total message, nor changes file
meta-data in a manner that would affect recursion, nor has a POSIX
mandate to support recursion, the use of find -exec touch (or
find|xargs) is preferable.
And for other tools that must report totals, like wc, we still don't
want to add recursion - it is easier to have wc support arbitrarily long
lists of safe file names via 'find -print0 | wc --files0-from=-' than to
make wc recursive.
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org