title: Linux shell script for delete old files from ftp
body: <p>There is a problem - need to store the database backup on the FTP. On the FTP should not be more than 10 back-ups, ie, After you add backup to FTP should be removed, the oldest files to make the total number of files can not exceed 10 pieces.
  How can we implement such a removal from the ftp?
  I'm trying to write a script, but does not work delete:
  </p>
  
  <pre><code>x=1
  ftp -vn $FTP_SERVER&lt;&lt;!
  user $FTP_LOGIN $FTP_PASSWORD
  binary
  put $DUMP_FILE_NAME
  
  for i in `ls -t` do
      if [ $x -le $keep ] then
          ((x++))
          continue
      fi
      delete $i
  done
  
  bye
  EOF
  &lt;/i&gt;
  </code></pre>