lftp的man手册:http://lftp.yar.ru/lftp-man.html

mirror的解释如下:

现有需求如下:

1、下载匹配某些表达式的文件,例如:Z9200_201211050934.bin等随时间而变化的文件

2、只下载最近1小时内的文件

3、只下载最新的文件

 

用法:

1、登陆ftp:lftp ftp://username:password@yourip/your/path

2、镜像文件:mirror -I Z9200*.bin --newer-than='now-1hours' --only-newer . /path/to/local

(测试发现此时的--delete-first选项不生效,原因未知,转一定时删除文件的脚本: 

 
  
  1. find /data/tomcat/tomcat-3g/logs -type f -mtime +10 -exec rm -f {} \; 
  2. 说明:/home/wwwroot是查找文件的路径。 
  3.    -type f是指定文件类型为普通文件。 
  4.    -mtime +30是指修改时间距离现在30天的文件。 
  5.    -exec rm -f指执行删除匹配出来的文件并且不提示。 

 

若出现中文乱码,可这样修正,登陆之后:

set ftp:charset "gbk"

set file:charset "utf-8"

 

若文件以时间戳为文件名,则可用:

FILE_NAME=Z_RADR_I_Z9200_$(date +%Y%m%d%H --date="-9 hours")*.bin

 

man手册上说--include RX,RX使用egrep参数,暂时不会用,因为这里使用了--include-glob选项,其中的--newer-than使用的是at的语法,两个man手册,链接:

at的man手册:http://os.51cto.com/art/201108/282824.htm

grep的man手册:http://os.51cto.com/art/201108/285119.htm