bash脚本在远程服务器上获取修改后的文件

时间:2013-07-15 15:39:09

标签: bash curl libcurl

如果修改日期超过3天,我想连接到安全的ftp服务器并检查目录中的每个文件。

希望使用CURL使用bash脚本实现此目的。

这是我尝试过的:

for i in `curl  -l -k --ftp-ssl ftp://"$ftp_username":"$ftp_password"@$ftp_ip:$ftp_port/$ftp_path/ `; do
{

    echo "Checking the modification date of $i";

    if ["$(( $(date +"%s") - $(stat -c "%Y" $i) ))" -gt "259200" ]; then
        echo "modified file found ";
    else
        echo "no modified file found";
    fi
};
done;

我收到此错误:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0  3266    0     0   6980      0 --:--:-- --:--:-- --:--:--  7525
Checking the modification date of products
stat: cannot stat `products': No such file or directory
./remove_products.sh: line 18: 1373903124 -  : syntax error: operand expected (error token is "-  ")

我做错了什么?

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:1)

变化:

if ["$(( $(date +"%s") - $(stat -c "%Y" $i) ))" -gt "259200" ]; then

为:

if [ "$(( $(date +"%s") - $(stat -c "%Y" $i) ))" -gt "259200" ]; then

[周围的空格是必需的。

相关问题