The first problem I can see is that
your output of find will have spaces in it
an example find command that handles spaces would be:
find . -type f -mtime +30 -exec rm "{}" \;
which will just "rm" each file found.
So if you want one action on each file this
should do it.
If you want to tar a whole file list
then I suggest you use:
tmp="/tmp/$$whatever"
find . -type f > $tmp
tar -cvf xxx.tar -T $tmp
rm -f $tmp
Of course you can change it to run your
commands :-)
In both cases it also doesn't matter how many
files there are
but with shell variables there is a size limit
the way you are currently doing it.
-Cheers
-Andrew Smith
--
MS ... if only he hadn't been hang gliding!
> Hello,
> I've got a cronjob on my ftp server that runs this script:
>
>
> #!/bin/sh
> set -x
>
> # quickie to move old files to storage and wipe really old stored files
>
> BASE=/var/ftp/ # base tree
> USERS=users # user accounts
> STORAGE=storage # storage area
> RECENT=3 # age of "recent" files
> (move)
> OLD=30 # age of "old" files
> (wipe)
>
> cd $BASE # go to top level
>
> # find all recent files and throw them to storage
> RECENTFILES=`find $USERS -type f -mtime +$RECENT -print` # find
> files tar cpf - "$RECENTFILES" | (cd $STORAGE ; tar xpf -) # copy
> 'em #rm -f $RECENTFILES # wipe the
> originals
>
> # find all old files and wipe 'em
> find $STORAGE -type f -mtime +$OLD -print | xargs rm -f
>
> The error output is:
>
> + BASE=/var/ftp/
> + USERS=users
> + STORAGE=storage
> + RECENT=3
> + OLD=30
> + cd /var/ftp/
> ++ find users -type f -mtime +3 -print
> + RECENTFILES=users/ftp1/VPN3000 Universal.zip
> users/rick-PCBA/fab drawings for 410-00047 rev 11.zip
> users/rick-PCBA/Gerbers 410-00047.zip
> + tar cpf - 'users/ftp1/VPN3000 Universal.zip
> users/rick-PCBA/fab drawings for 410-00047 rev 11.zip
> users/rick-PCBA/Gerbers 410-00047.zip'
> tar: users/ftp1/VPN3000 Universal.zip\nusers/rick-PCBA/fab drawings for
> 410-00047 rev 11.zip\nusers/rick-PCBA/Gerbers 410-00047.zip: Cannot
> stat: No such file or directory
> + cd storage
> + tar xpf -
> tar: Error exit delayed from previous errors
> + find storage -type f -mtime +30 -print
> + xargs rm -f
>
>
>
> What I can't get to work is file names with spaces in them. Tar splits
> up the names. Can someone tell me how to accomplish this?
>
> Thanks,
>
> ...Joe
_______________________________________________
Seawolf-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/seawolf-list