# find, remove, and ftp......

**URL:** <https://community.unix.com/t/find-remove-and-ftp/143103>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [June 24, 2002, 8:22pm UTC](https://community.unix.com/t/find-remove-and-ftp/143103 "2002-06-24T20:22:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.herlihy](https://community.unix.com/letter_avatar/peter.herlihy/32/5_5575768a8748004e209b776fc1b2916d.png) [@peter.herlihy](https://community.unix.com/u/peter.herlihy)\
**Post date:** [June 24, 2002, 8:22pm UTC](https://community.unix.com/t/find-remove-and-ftp/143103/1 "2002-06-24T20:22:16Z")

</div>

I have a script that is run each night by cron. This script generates an extract then places it into an 'extracts' folder and also ftp's a copy to another server.

I have set up the script to remove any files in the extracts folder greater than 28 days old (this occurs each time the script is run). This is the command.

find ${WORKdir}/extracts/ -mtime +29 -exec rm {} \; &&

Now I also want this function to occur in the folder on the other server - preferably using ftp. Here is the ftp activity I already have.

if [-s ${EXTfile}]  
then  
ftp -n ${FTPserver} \<\< cmd  
user ${FTPid} ${FTPpwd}  
cd ${FTPlocation}  
lcd ${WORKdir}/extracts  
put ${SHORTfile}  
quit  
cmd  
fi

Can FTP do anything like this - by using unix commands somehow?

---

<div class="post-metadata">

**Author:** ![Kevin\_Pryke](https://community.unix.com/letter_avatar/kevin_pryke/32/5_5575768a8748004e209b776fc1b2916d.png) [@Kevin\_Pryke](https://community.unix.com/u/Kevin_Pryke)\
**Post date:** [June 25, 2002, 6:51am UTC](https://community.unix.com/t/find-remove-and-ftp/143103/2 "2002-06-25T06:51:50Z")

</div>

You could create a file of the filenames you have deleted on your local host & then use a script to create a list of commands for ftp

eg. (filelist is the list of deleted files)

echo user ${FTPid} ${FTPpwd} \> ftpfile  
for name in `cat ${WORKdir}/extracts/filelist `  
{  
echo delete $name \>\> ftpfile  
}  
echo quit \>\> ftpfile

you can then do

ftp -n ${FTPserver} \< ftpfile

to delete them

you'll have to use the absolute file names in the example above.
