Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ftp command to remove bunch of files

I can download files using wget "ftp://user:pass@host/prefix*, but I cannot remove downloaded files from FTP. Any easy solution to do this in bash script?

like image 722
Kai Avatar asked Feb 03 '26 14:02

Kai


2 Answers

As WhoSayln and Skilldrick said, you should use ftp to download files, and remove files from the server (if you have the permission to).

But in your question you're saying "I cannot remove downloaded files from FTP". Do you want to remove the local files from your computer (the ones you just downloaded from ftp server) or the files on remote server?

If is local, then just a rm -f file will do it :p

But if it's remote, and this is running on a script (a typical job in a batch) so try something like:

jyzuz@dev:/jean> ftp -n -i remoteserver.com << EOF
> user $username $password
> cd /remote/directory/
> rm filename.txt
> bye
> EOF

More or less? =P

like image 87
jyz Avatar answered Feb 05 '26 04:02

jyz


If you need to script some operation on a FTP server, I would point you to lftp.

Main website

Tutorial

like image 33
Daniele Venzano Avatar answered Feb 05 '26 06:02

Daniele Venzano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!