Re: problem w/ -exec option of find

From: Dean Darlison (spam_at_aol.com)
Date: 02/25/04


Date: Wed, 25 Feb 2004 17:06:12 +0000

Ed Stevens wrote:

> Using ksh on Solaris . . .
>
> Trying to solve the problem of applying some processing to each file
> matching a name pattern. The critical code looks like this:
>
> #!/bin/ksh
>
> decrypt_file()
> {
> echo `date` Decrypting $1 >>$TRACE
>
> # code to process the file goes here
> }
> <snip>
>
> #######################################################################
> # decrypt the input file
> #
> echo `date` Starting Decryption >>$TRACE
>
> find ${LOCAL_FTP_DIR} \( -name "${VENDOR_DATA_FILE}*" \) -exec
> decrypt_file {} \;
>
<snip>

  the function is not available in the shell invoked by the exec option.
Something like the following would achieve what you want: -

for i in `find ${LOCAL_FTP_DIR} \( -name "${VENDOR_DATA_FILE}*" \)`
do
   decrypt_file $i
done

Cheers,
  Dean.

-- 
Email addresses are to be ignored.
If I am too busy to read the news group, I am too busy to read my email.