[mdlug] Finding something for a cat

Jeff Hanson jhansonxi at gmail.com
Mon Aug 16 21:33:51 EDT 2010


On Mon, Aug 16, 2010 at 9:28 PM, Mark Montague <markmont at umich.edu> wrote:
> Redirects are interpreted by the shell, not by find, and find does not
> invoke a shell for the commands it runs via the -exec action, it just passes
> individual arguments you give it to something like the execve() system call.
>  ("man 2 execve" for more information).
>
> You can solve the problem by telling find to invoke a shell for you for each
> command -- the shell will then set up the I/O redirection before running the
> cat command.  Try the following (not tested):
>
> find . -type d -execdir /bin/sh -c 'cat {}/alternate-i386-desktop.cfg
> /srv/tftpboot/kickstart/always_added_packages.txt>
>  {}/standard-alternate-i386-desktop.cfg' \;
>
>
> Note the new position of the single quotes -- the entire cat command,
> including the {} substituions made by find, plus the redirection, are a
> single argument that gets passed to /bin/sh to run.
>

I had a feeling that was the problem.  I was messing around with bash
to get the same thing with the eval command.  Looks like I had the
wrong one.  It works now.  Thanks.



More information about the mdlug mailing list