[GRLUG] file backup script

Michael Mol mikemol at gmail.com
Tue Jul 17 19:29:41 EDT 2007


On 7/17/07, Michael Mol <mikemol at gmail.com> wrote:
>
> Ow!  You're running a find operation for each file.
>
> Here's a more efficient script: (Untested...I don't have decent access
> to a Linux box at the moment.)
>
> find /dir/to/start/search >/tmp/mytmpindex$$
> grep -f file.txt /tmp/mytmpfile > /tmp/mytmpfoundfiles$$
>
> for i in $(cat /tmp/mytmpfoundfiles$$)
> do
> cp -p ${FILE} /local/dir #copy file from remote dir to local dir
> done
>
> rm /tmp/mytmp*$$

erp...try this instead:


ind /dir/to/start/search >/tmp/mytmpindex$$
grep -f file.txt /tmp/mytmpfile > /tmp/mytmpfoundfiles$$

for i in $(cat /tmp/mytmpfoundfiles$$)
do
cp -a "$i" /local/dir #copy file from remote dir to local dir
done

rm /tmp/mytmp*$$

-- 
:wq


More information about the grlug mailing list