[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: find and copy [Solved]



On Fri, Sep 06, 2013 at 12:52:09PM +1000, Zenaan Harkness wrote:
> 
> Sorry, I forgot you needed renaming. So -I option to xargs may be
> useful for you.
> 
> OK, try something like this:
> 
>   sh -c 'cp "$0" /tmp/data.backup/${HOSTNAME}".${0:2}"' {} \;
> 
> find /tmp/var -mmin -60 -a -iname '*.sql' -type f \
>  | xargs -n 50 basename -a \
>  | xargs -I NAME echo cp /tmp/data.backup/NAME \
>  /tmp/var/$HOSTNAME.`date +%Y%m%d-%H.%M.%S.%N`.NAME.backup
> 
> You should be bonza, fab, good to go :)
> 
> Let us know if that does the trick,
> Zenaan

Hi Zenaan,

Well I don't know about bonza, and I thought fab was back in the sixties :).
But you got it, with two minor caveats. There is no -a for basename, and (I
wouldn't expect you to really catch this, just pointing it out) the directory
names are backwards in the cp statement. I want to copy from /tmp/var/ to
/tmp/data.backup.

But you get the kudos, and my appreciation for putting the time into this. I've
been stuck taking care of some broken databases, but then that is my job and I
do actually enjoy it. :)

Zenaan, thanks for the help.

Craig


Reply to: