Subject: Re: creating many files using "find"

From: [email-masked] (Casper H.S. Dik)
Date: 28 Oct 1993 09:50:02 GMT

Timothy Dry <[email-masked]> writes:

>  I'm trying to create a particular file in every directory
>within a particular tree.  I believe I should be able to do
>the following:

>smogalert(~)% find . -type d -exec touch {}/xyz \;
>touch: /xyz cannot create
>touch: /xyz cannot create
>touch: /xyz cannot create
>^C

>  Unfortunately, as you can see, it tries to create the files
>in "/" as if the braces were never used.  The directory in
>the example has many directories under it.  The system is
>Solaris 5.2 on a SparcServer 1000.

The {} is only expanded in the argument to exec if it appears as
a lone argument.  Not when it appears as part of an argument. Fix:
upgrade to GNU find:

% /usr/bin/find  /var/tmp -type d -exec echo '{}/foo' \;
{}/foo
{}/foo
% /opt/gnu/bin/find /var/tmp -type d -exec echo '{}/foo' \;
/var/tmp/foo
/var/tmp/unbundled/foo

Casper