in reply to Re: Searching a directory tree
in thread Searching a directory tree

Thanks for your reply Dave.

Unless I'm missing something obvious I think that is what I am doing already.

My find command isfind/home/www/*/logs/weekly i.e find all subdirectories, including new ones created since the job was last run, below /home/www that contain a logs sub-directory containing the file "weekly". This is what I want to do. The job will be run weekly using cron. Find2perl writes the code to find the files correctly but also creates a blanksub wanted{} sub-routine each time the cronned script is run.

I then want to pass the gzip and mail commands to the "wanted" sub-routine.

Any ideas?

Thanks in advance.

Replies are listed 'Best First'.
Re: Re: Re: Searching a directory tree
by davorg (Chancellor) on Aug 10, 2001 at 15:34 UTC

    I think you're missing the power of the Unix find coomand :) find will not only find the file that you want, but it will also carry out the correct operations on them. find2perl will then fill in the &wanted subroutine with the correct commands to mirror that behaviour. For example, your full find command would be something like this:

    find /home/www/*/logs/weekly -exec "gzip {} \| mail me@somewhere \;"

    Try passing that to the find2perl command and you'll get stuff in the &wanted subroutine.

    See the find man page for more details of cool things you can do with find.

    --
    <http://www.dave.org.uk>

    Perl Training in the UK <http://www.iterative-software.com>

      You're right. I was but now I've seen the light :).

      Many thanks Dave.

      Wylie