Question : can you ftp only a set number of files?

i have a location that will have lots of files in at any one time (all csv files), but i only want to ftp approx 10 files at a time (being the 10 oldest files), using a wildcard as the filenames will always be different. Does anyone know if this is possible and if so...how.
cheers,
aidy.

Answer : can you ftp only a set number of files?

aidy.. this is what the script would look like. The shell needs to be csh or tcsh.
The 1st line will list 10 file names and copy them to a new directory called avitest. In you case this probably needs to be a move (mv) rather than a copy. You can also remove the echo since you dont need to see which files were moved. Create a file called test.sh and copy the files below

#!/bin/tcsh
set lstfiles=`ls -altr | awk '{ print($9) }' | grep . | sed 10q | tr "\n" " "`
foreach file ($lstfiles)
   echo $file
   cp $file ./avitest/
end

once this is done. chmod +x test.sh and run the script and you should see the files copied to the new location.

For this to be done automatically you can run this script as frequently as you need from a cron job.

Random Solutions  
 
programming4us programming4us