0

How do we connect to a FTP from a shell script and pull the last 14 (or n) modified files by timestamp and place them on one of the folders from the current host. I try to use

mget

, but can we specify to get the files based on the timestamp and the number of files to get... Please advise... Thanks in advance...

Dhruuv
  • 343
  • 10
  • 24

1 Answers1

1

You can define an ftp macro (macdef) and automate your login (in your ~/.netrc file) and in youe script fetch a file listing; sort the listing by date with awk or sort -k in your script to build a list of N files that you want to fetch; then simply loop through the list and fire up ftp to fetch them.

It might be easier to use curl. and probably would more portable to use something like perl and Net::FTP.

G. Cito
  • 6,210
  • 3
  • 29
  • 42